Is there a way to find out the size of the original file which is inside a GZIP file in java?
As in, I have a file a.txt of 15 MB which has been GZipped to a.gz of s
public class ReadStream {
public static void main(String[] args) {
try {
RandomAccessFile raf = new RandomAccessFile(new File("D:/temp/temp.gz"), "r");
try {
raf.seek(raf.length() - 4);
int b4 = raf.read();
int b3 = raf.read();
int b2 = raf.read();
int b1 = raf.read();
int val = (b1 << 24) | (b2 << 16) + (b3 << 8) + b4;
System.out.println(val);
raf.close();
} catch (IOException ex) {
Logger.getLogger(ReadStream.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (FileNotFoundException ex) {
Logger.getLogger(ReadStream.class.getName()).log(Level.SEVERE, null, ex);
}
}
}