I am printing a chunk from inputstream by using
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());
}
instead of printing from skip to end, i want to compress the bytes between skip to end (in.read())
can someone help me to first compress and then decompress the same
i tried this
FileOutputStream fos = new FileOutputStream(ChunkZipName);
GZIPOutputStream chunkZipper = new GZIPOutputStream (fos);
for (int i = skip; i < end; i++) {
chunkZipper.write(in.read()); }
but it write only 10bytes.. remaining bytes r skipped … is this correct usage of GZIPOutputStream ???
Just wrap a
GZIPOutputStream/GZIPInputStreamaround your real stream.BTW:
If you want to really skip exactly 1024 bytes you have to check the return value of
skipand repeat with the remaining bytes because in some cases (buffers) the method does not skip fully to the desired position.