Java 如何包装netty';s ChannelBufferInputStream与充气数据的充气输入流?

Java 如何包装netty';s ChannelBufferInputStream与充气数据的充气输入流?,java,inputstream,netty,Java,Inputstream,Netty,我正在使用netty,必须解析ChannelBufferInputStream中的二进制数据。以下是我正在使用的代码: ins.skipBytes(14); // skip 14 bytes header byte[] b = new byte[195]; // note that 195 is the length of data after inflation (new InflaterInputStream(ins)).read(b, 0, 195); 这与预期的一样,但它将Channe

我正在使用netty,必须解析ChannelBufferInputStream中的二进制数据。以下是我正在使用的代码:

ins.skipBytes(14); // skip 14 bytes header
byte[] b = new byte[195]; // note that 195 is the length of data after inflation
(new InflaterInputStream(ins)).read(b, 0, 195);
这与预期的一样,但它将ChannelBufferInputStream上的标记设置为195字节之后。 不用说,标记应该在小于195字节后设置


是否可以从inputstream读取“实际”字节数,以便我自己设置标记?或者是否有其他方法在netty中膨胀ChannelBuffer的数据?

在不知道较大的代码流是什么样子的情况下,很难推荐最佳做法,但假设您正在读取传入的网络流,更好的模式可能是使用一系列管道处理程序,如:

HeaderHandler -->  decoder, returns null until 14 bytes are read
   InflaterDecoder --> Inflates the remainder (will ZLibDecoder work ?)
      AppHandler -->  Receives the inflated buffer 
但是为了直接回答第一个问题,威尔引用javadoc:

返回此流到目前为止读取的字节数