小编Nic*_*heo的帖子

Netty java从ByteBuf获取数据

如何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)

java netty

22
推荐指数
2
解决办法
3万
查看次数

有趣的运营商'==='在Kotlin

什么操作员'==='在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 = 1000val b: Int = 1000不在范围内-128..127,但仍然===是真实的或编译器在某些情况下明白,它可以采取一个价值?

syntax kotlin

20
推荐指数
1
解决办法
4375
查看次数

标签 统计

java ×1

kotlin ×1

netty ×1

syntax ×1