我想从zip文件中删除文件,而无需在android中进行解压缩。我第一次使用下面的代码如何在Android中删除zip文件中的文件
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工作做到了与Java,在logcat的
java.lang.NoClassDefFoundError: java.nio.file.Paths
Isearched发生了用于分辨率错误并得到了一个暗示,Android没有'java.nio.file.Paths'这个东西, 我正在寻找一个替代解决方案可以zip4j或TrueZip将在这里做诡计,
我试过用truezip,b使用此代码
TFile archive = new TFile("archive.zip");
for (String member : archive.list())
System.out.println(member);
但是archive.list()返回null,但是archive.length正在返回其正确的文件大小。
我不知道我在这里做错了什么,我在一个罐子里下载了truezip 7.7。但我得到一个错误,当我给这个import de.schlichtherle.io.File
请帮
您正在使用什么版本的Java
我猜你为TrueZIP下载了错误的JAR文件。请查看https://truezip.java.net/kick-start/no-maven.html。另请注意,TrueZIP处于维护模式。对于新项目,您应该使用TrueVFS。相应的页面是https://truevfs.java.net/kick-start/no-maven.html。 – 2015-01-22 12:13:12