我想从 zip 文件中删除一个文件而不在 android 中提取它。我首先使用以下代码使用 java
Path zipFilePath = Paths.get(filePaths); //gave the path of the zip with zip file name
try( FileSystem fs = FileSystems.newFileSystem(zipFilePath, null) ){
Path pathInZipfile = fs.getPath(reVsl3); //reVsl3 String which holds the name of the file to be deleted in the zip file
zipDelLoc=reVsl3; //just assigning it for future use
System.out.println("About to delete an entry from ZIP File" + pathInZipfile.toUri() );
// Execute Delete
Files.delete(pathInZipfile);
System.out.println("File successfully deleted");
}
catch (IOException e) {
System.out.println(e+"Error here?");
}
这在netbeans中运行良好,但在ADT中不起作用,logcat中出现错误
java.lang.NoClassDefFoundError: java.nio.file.Paths
我搜索了一个解决方案,并得到一个提示,android没有'java.nio.file.Paths'这个东西,我正在寻找一个替代解决方案,zip4j或TrueZip可以在这里解决问题,
我尝试使用 truezip,但使用此代码
TFile archive = new TFile("archive.zip");
for (String member : archive.list())
System.out.println(member);
但archive.list() 返回null,但archive.length 返回其正确的文件大小。
我不知道我在这里做错了什么,我在一个 jar 中下载了 truezip 7.7。但是当我给出这个时我得到了一个错误import de.schlichtherle.io.File
请帮忙