I think that in your case, the fact that the zipfile is a container that can store many files (and thus makes you navigate the right contents of the file every time you open it) makes the situation more complicated, as you state that each zip file contains only one text file. Maybe it’s a lot easier to just gzip a text file (gzip is not a container, but only a compressed version of your data). And this is a very simple use:
GZIPInputStream gis = new GZIPInputStream(new FileInputStream("file.txt.gz"));
BufferedReader in = new BufferedReader(new InputStreamReader(gis) );
The product of them is equally simple:
GZIPOutputStream gos = new GZIPOutputStream(new FileOutputStream("file.txt.gz"));
source
share