List<FileData> fileDatas = new ArrayList<FileData>();
File archiveFile = new File(tmp, "pack.zip");
File unpack = new File(tmp, "unpack");
ArchiveBean archiveBean = new ArchiveBean();
try {
archiveBean.afterPropertiesSet();
} catch (Exception e1) {
want.fail();
}
try {
// for (int i = 0; i < 10; i++) {
// files[i] = new File(tmp, "archiveTest_" + i + ".txt");
// datas[i] = getBlock((i + 1) * 1024);
// NioUtils.write(datas[i], files[i]);
//
// FileData filedata = new FileData();
// filedata.setPath(files[i].getPath());
// fileDatas.add(filedata);
// }
archiveBean.pack(archiveFile, fileDatas, new ArchiveRetriverCallback<FileData>() {
public InputStream retrive(FileData source) {
try {
return new FileInputStream(new File(source.getPath()));
} catch (FileNotFoundException e) {
e.printStackTrace();
want.fail();
}
return null;
}
});
// 开始解压
List<File> result = archiveBean.unpack(archiveFile, unpack);
want.bool(result.size() == fileDatas.size());
// File dir = new File(unpack, archiveFile.getParent());
// File[] unpackFiles = dir.listFiles();
//