This is my code:
WritableByteChannel channel = null;
GZIPOutputStream out = null;
try {
channel = Channels.newChannel(new FileOutputStream("C:\\temp\\111.zip"));
out = new GZIPOutputStream(Channels.newOutputStream(channel));
for (long i = 0; i < 10000000000; i++) {
out.write(("string" + i + "\n").getBytes());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (channel != null) {
channel.close();
}
} catch (Exception e) {
}
try {
if (out != null) {
out.close();
}
} catch (Exception e) {
}
} }
I get zip but it's contents is damaged.