2
我想解压缩部分分割的文件(file.part1,file.part2,file.part3 ...)。 我把所有的部件放在同一个文件夹中。在互联网上,我只找到了解压缩单个文件的例子。Android:如何解压缩部分分割的文件
有人知道是否有API来做到这一点?
我想解压缩部分分割的文件(file.part1,file.part2,file.part3 ...)。 我把所有的部件放在同一个文件夹中。在互联网上,我只找到了解压缩单个文件的例子。Android:如何解压缩部分分割的文件
有人知道是否有API来做到这一点?
压缩API在Android上的Java AFAIK上没有变化。在Java中,您可以轻松地解压缩多卷文件。我发布了一些Java代码,您应该可以在Android上运行一些小的(如果有的话)修改。
public class Main {
public static void main(String[] args) throws IOException {
ZipInputStream is = new ZipInputStream(new SequenceInputStream(Collections.enumeration(
Arrays.asList(new FileInputStream("test.zip.001"), new FileInputStream("test.zip.002"), new FileInputStream("test.zip.003")))));
try {
for(ZipEntry entry = null; (entry = is.getNextEntry()) != null;) {
OutputStream os = new BufferedOutputStream(new FileOutputStream(entry.getName()));
try {
final int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
for(int readBytes = -1; (readBytes = is.read(buffer, 0, bufferSize)) > -1;) {
os.write(buffer, 0, readBytes);
}
os.flush();
} finally {
os.close();
}
}
} finally {
is.close();
}
}
}
的代码是从较旧的SO问题,其可以被发现here。
它的工作原理,谢谢! – PauloBueno 2012-08-02 20:43:22