【发布时间】:2011-02-28 11:00:54
【问题描述】:
我有一个问题要解决。 我有 tar.gz 压缩文件,我希望将内容保留为流,就像 Zipfile 允许使用 zipFile.getInputStream(zipEntry) 方法一样。我已经使用 ant 库实现了,代码:
TarInputStream is = new TarInputStream(gzipInputStream); while((entryx = is.getNextEntry()) != null) { if (entryx.isDirectory()) 继续; 别的 { InputStream tmpIn = new StreamingTarEntry(is, entryx.getSize()); BufferedReader gzipReader = null; // simple loop to dump the contents to the console
try {
gzipReader = new BufferedReader(
new InputStreamReader(
new GZIPInputStream(
tmpIn)));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (gzipReader !=null){
buffer.add(gzipReader);
}
}// end of while
is.close();
在我将 BUFFERreader 放入我的linkedList,然后在主目录中检索它并想要打印缓冲区的内容后,我有一个例外: java.io.EOFException:ZLIB 输入流的意外结束 在 java.util.zip.InflaterInputStream.fill(未知来源)
谁能帮帮我???
【问题讨论】:
-
对不起,伙计,没有听懂你想说什么:(
-
当我打开文件 tar.gz 的流时,我可以打印所有单个文件的内容,创建 BufferReader reader= new BufferedReader( new InputStreamReader( new GZIPInputStream( tmpIn)));然后使用 read.reaLine()...所以我想要一个将 Buffeader 放入 LInkedLIst 中,然后将缓冲区管理到我的程序的 main() 中......现在清楚了吗???
标签: java ant tar compression