Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 压缩和解压缩inputstream中的字节块_Java_Inputstream_Compression - Fatal编程技术网

Java 压缩和解压缩inputstream中的字节块

Java 压缩和解压缩inputstream中的字节块,java,inputstream,compression,Java,Inputstream,Compression,我正在使用从inputstream打印块 int skip = in.skip(1024); //skip first 1024b int end = in.available(); // remaining size in b for (int i = skip; i < end; i++) { //prints chunk of data from in-stream from skip till end System.out.println(in.read(

我正在使用从inputstream打印块

int skip = in.skip(1024); //skip first 1024b

int end = in.available(); // remaining size in b

for (int i = skip; i < end; i++) {

    //prints chunk of data from in-stream from skip till end

     System.out.println(in.read()); 

} 
int skip=in.skip(1024)//跳过第一个1024b
int end=in.available();//剩余尺寸为b
for(int i=skip;i
我希望压缩从跳过到结束之间的字节(in.read()),而不是从跳过到结束进行打印 有人能帮我先压缩然后再解压缩吗


我试过这个

FileOutputStream fos = new FileOutputStream(ChunkZipName);
GZIPOutputStream chunkZipper = new GZIPOutputStream (fos); 
for (int i = skip; i < end; i++) {
chunkZipper.write(in.read()); }
FileOutputStream fos=新的FileOutputStream(ChunkZipName);
GZIPOutputStream chunkZipper=新的GZIPOutputStream(fos);
for(int i=skip;i

但是它只写10字节。。已跳过剩余的字节。。。这是GZIPOutputStream的正确用法吗

只需将一个
gzip输出流
/
gzip输出流
环绕在真实流周围

out = new GZIPOutputStream (out);
顺便说一句:
如果确实要跳过1024个字节,则必须检查
skip
的返回值,并重复剩余的字节,因为在某些情况下(缓冲区)该方法不会完全跳到所需的位置。

只需将一个
gzip输出流
/
gzip输出流
环绕在真实流周围

out = new GZIPOutputStream (out);
顺便说一句:
如果确实要跳过1024个字节,则必须检查
skip
的返回值,并重复剩余的字节,因为在某些情况下(缓冲区),该方法不会完全跳过到所需的位置。

使用GZipInputStream和GZipOutputStream。使用GZipInputStream和GZipOutputStream。