use of herddb.utils.SimpleBufferedOutputStream in project herddb by diennea.
the class ZIPUtils method unZip.
public static List<File> unZip(InputStream fs, File outDir) throws IOException {
try (ZipInputStream zipStream = new ZipInputStream(fs, StandardCharsets.UTF_8)) {
ZipEntry entry = zipStream.getNextEntry();
List<File> listFiles = new ArrayList<>();
while (entry != null) {
if (entry.isDirectory()) {
entry = zipStream.getNextEntry();
continue;
}
String normalized = normalizeFilenameForFileSystem(entry.getName());
File outFile = new File(outDir, normalized);
File parentDir = outFile.getParentFile();
if (parentDir != null && !parentDir.isDirectory()) {
Files.createDirectories(parentDir.toPath());
}
listFiles.add(outFile);
try (FileOutputStream out = new FileOutputStream(outFile);
SimpleBufferedOutputStream oo = new SimpleBufferedOutputStream(out)) {
IOUtils.copyLarge(zipStream, oo);
}
entry = zipStream.getNextEntry();
}
return listFiles;
} catch (IllegalArgumentException ex) {
throw new IOException(ex);
}
}
Aggregations