Search in sources :

Example 11 with SimpleBufferedOutputStream

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);
    }
}
Also used : SimpleBufferedOutputStream(herddb.utils.SimpleBufferedOutputStream) ZipInputStream(java.util.zip.ZipInputStream) ZipEntry(java.util.zip.ZipEntry) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Aggregations

SimpleBufferedOutputStream (herddb.utils.SimpleBufferedOutputStream)11 IOException (java.io.IOException)10 Path (java.nio.file.Path)10 ManagedFile (herddb.utils.ManagedFile)9 DataStorageManagerException (herddb.storage.DataStorageManagerException)8 ArrayList (java.util.ArrayList)8 ExtendedDataOutputStream (herddb.utils.ExtendedDataOutputStream)7 PostCheckpointAction (herddb.core.PostCheckpointAction)6 LogSequenceNumber (herddb.log.LogSequenceNumber)6 XXHash64Utils (herddb.utils.XXHash64Utils)3 KeyToPageIndex (herddb.index.KeyToPageIndex)2 BLinkKeyToPageIndex (herddb.index.blink.BLinkKeyToPageIndex)2 Index (herddb.model.Index)2 Table (herddb.model.Table)2 ODirectFileOutputStream (herddb.utils.ODirectFileOutputStream)2 ProgressListener (herddb.backup.ProgressListener)1 HDBConnection (herddb.client.HDBConnection)1 HerdDBConnection (herddb.jdbc.HerdDBConnection)1 MetadataStorageManagerException (herddb.metadata.MetadataStorageManagerException)1 Transaction (herddb.model.Transaction)1