I have a zip file which I want to convert to gzip and write it back to the filesystem. How can I do this?
I already have this code to compress a file to gzip:
private static void compressGzipFile(String file, String gzipFile) {
try {
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(gzipFile);
GZIPOutputStream gzipOS = new GZIPOutputStream(fos);
byte[] buffer = new byte[1024];
int len;
while ((len=fis.read(buffer)) != -1) {
gzipOS.write(buffer, 0, len);
}
// Close resources
gzipOS.close();
fos.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Now I need code to convert the zip file into a gzip file.