0

在分析结果文件时,该值被正确写入,所以setUnixMode()可能工作正常,但getUnixMode()总是返回 0。有没有人有这方面的经验?

File file = new File("Test.file");
ZipArchiveOutputStream zipArchiveOutputStream = new ZipArchiveOutputStream(new FileOutputStream(file));   
ZipArchiveEntry zipArchiveEntry = new ZipArchiveEntry("Entry");  
zipArchiveEntry.setUnixMode(0744);
zipArchiveOutputStream.putArchiveEntry(zipArchiveEntry);
zipArchiveOutputStream.write("TestBytes".getBytes());
zipArchiveOutputStream.closeArchiveEntry();
zipArchiveOutputStream.close();
                        
ZipArchiveInputStream zipArchiveInputStream = new ZipArchiveInputStream(new FileInputStream(file));
ZipArchiveEntry entryOut = zipArchiveInputStream.getNextZipEntry();
System.out.println(entryOut.getUnixMode());
4

1 回答 1

0

当平台 != PLATFORM_UNIX 时,getUnixMode() 返回 0(源代码请参见此处)。所以你还必须指定平台:zipArchiveEntry.setPlatform(ZipArchiveEntry.PLATFORM_UNIX)

于 2021-08-16T17:32:57.187 回答