从套接字(缓冲区)获取数据
BufferedReader is = new BufferedReader(new InputStreamReader(download.getInputStream()));
数据解压
Inflater decompresser = new Inflater();
decompresser.setInput(buffer.toString().getBytes());
byte[] dataBytes = new byte[8388608];
int resultLength = decompresser.inflate(dataBytes);
decompresser.end();
System.out.println("decompressed" + new String(dataBytes, 0, resultLength)+ " RESULTLENGHT " +resultLength);
发送 1000 字节,压缩 ZLIB 和轮流(800-900 字节)但我不知道发送的确切大小。我需要一次从套接字读取 1 个字节并立即解压缩它,直到解压缩数据的总大小等于 1000 个字节。
要一次读取一个字节,我这样做:
StringBuilder buffer = new StringBuilder();
StringBuilder unpackbuffer = new StringBuilder();
do buffer.append((char)is.read());
while(buffer.charAt(buffer.length()-1) != '|' && (byte)buffer.charAt(buffer.length()-1) != -1);
我如何填写这个循环解包缓冲区?并检查它的大小?对不起,我希望我的问题很清楚。