如何ByteBuf在下面的代码中有效地获取字节数组?我需要获取数组然后序列化它.
package testingNetty;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
public class ServerHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
System.out.println("Message receive");
ByteBuf buff = (ByteBuf) msg;
// There is I need get bytes from buff and make serialization
byte[] bytes = BuffConvertor.GetBytes(buff);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// Close the connection when an exception is raised.
cause.printStackTrace();
ctx.close();
}
}
Run Code Online (Sandbox Code Playgroud) 什么操作员'==='在Kotlin做什么?它是如何工作的?我们可以检查参考平等吗?
val a: Int = 10000
print(a === a) // Prints 'true'
val boxedA: Int? = a
val anotherBoxedA: Int? = a
print(boxedA === anotherBoxedA) // !!!Prints 'false'!!!
Run Code Online (Sandbox Code Playgroud)
但以防万一:
var a : Int = 1000
var b : Int = 1000
println(a === b) // print 'true' !!!
Run Code Online (Sandbox Code Playgroud)
VAL a: Int = 1000和val b: Int = 1000不在范围内-128..127,但仍然===是真实的或编译器在某些情况下明白,它可以采取一个价值?