为什么用apache compress解压时NoPointerExcepeion?
Why NoPointerExcepeion when decompression by apache compress?
click and see The NoPointerExcepeion
我生成了tar.gz个文件并发送了另外2个4个解压,但是他们的程序有上面的错误(他们的程序不是我创建的),只有一个文件有这个错误。
但是在我的电脑和他们的电脑上使用命令'tar -xzvf ***'时,没有出现问题...
所以我想让 2 知道我下面的程序出了什么问题:
public static void archive(ArrayList<File> files, File destFile) throws Exception {
TarArchiveOutputStream taos = new TarArchiveOutputStream(new FileOutputStream(destFile));
taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
for (File file : files) {
//LOG.info("file Name: "+file.getName());
archiveFile(file, taos, "");
}
}
private static void archiveFile(File file, TarArchiveOutputStream taos, String dir) throws Exception {
TarArchiveEntry entry = new TarArchiveEntry(dir + file.getName());
entry.setSize(file.length());
taos.putArchiveEntry(entry);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
int count;
byte data[] = new byte[BUFFER];
while ((count = bis.read(data, 0, BUFFER)) != -1) {
taos.write(data, 0, count);
}
bis.close();
taos.closeArchiveEntry();
}
堆栈跟踪看起来像是 Apache Commons Compress https://issues.apache.org/jira/browse/COMPRESS-223 中的错误,该错误已在 1.7 版(将近三年前发布)中修复。
click and see The NoPointerExcepeion
我生成了tar.gz个文件并发送了另外2个4个解压,但是他们的程序有上面的错误(他们的程序不是我创建的),只有一个文件有这个错误。
但是在我的电脑和他们的电脑上使用命令'tar -xzvf ***'时,没有出现问题...
所以我想让 2 知道我下面的程序出了什么问题:
public static void archive(ArrayList<File> files, File destFile) throws Exception {
TarArchiveOutputStream taos = new TarArchiveOutputStream(new FileOutputStream(destFile));
taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
for (File file : files) {
//LOG.info("file Name: "+file.getName());
archiveFile(file, taos, "");
}
}
private static void archiveFile(File file, TarArchiveOutputStream taos, String dir) throws Exception {
TarArchiveEntry entry = new TarArchiveEntry(dir + file.getName());
entry.setSize(file.length());
taos.putArchiveEntry(entry);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
int count;
byte data[] = new byte[BUFFER];
while ((count = bis.read(data, 0, BUFFER)) != -1) {
taos.write(data, 0, count);
}
bis.close();
taos.closeArchiveEntry();
}
堆栈跟踪看起来像是 Apache Commons Compress https://issues.apache.org/jira/browse/COMPRESS-223 中的错误,该错误已在 1.7 版(将近三年前发布)中修复。