我已经创建了一个应用程序,它将从 tar-archive 中提取单个文件。应用程序正确读取 *.tar,但是当我尝试提取文件时,应用程序只是创建具有正确文件名的新文件......文件为空(0kb)。所以...我可能只是创建新文件而不是提取...
在这一点上,我完全是一个初学者......
for(TarArchiveEntry tae : tarEntries){
System.out.println(tarEntries.size());
try {
fOutput = new FileOutputStream(new File(tae.getFile(), tae.getName()));
byte[] buf = new byte[(int) tae.getSize()];
int len;
while ((len = tarFile.read(buf)) > 0) {
fOutput.write(buf, 0, len);
}
fOutput.close();
} catch (IOException e) {
e.printStackTrace();
}
}