【发布时间】:2012-02-22 11:42:49
【问题描述】:
这是我的代码:
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) {
}
} }
我收到了 zip,但它的内容已损坏。
【问题讨论】: