public static void unzip(ZipInputStream in, File dir, PathFilter filter) throws IOException { if (filter == null) { unzip(in, dir); } else { unzip(in, dir, toPredicate(filter), Function.identity()); } }
protected static void zip(Blob blob, ZipOutputStream out) throws IOException { String entry = getFileName(blob); InputStream in = blob.getStream(); try { ZipUtils._zip(entry, in, out); } finally { in.close(); } }
public static String getEntryContentAsString(URL url, String entryName) throws IOException { try (InputStream resultStream = getEntryContentAsStream(url, entryName)) { return IOUtils.toString(resultStream, UTF_8); } }
public static void zip(File file, OutputStream out, String prefix) throws IOException { prefix = normalizePrefix(prefix); String name = normalizePrefix(prefix) + file.getName(); try (ZipOutputStream zout = new ZipOutputStream(out)) { _zip(name, file, zout); } }
public static void unzip(ZipInputStream in, File dir) throws IOException { unzip(in, dir, entry -> true, Function.identity()); }
if (!ZipUtils.isValid(blobStream)) { throw new ConversionException("not a valid iWork file"); if (ZipUtils.hasEntry(blobStream, IWORK_PREVIEW_FILE)) { try (InputStream previewPDFFile = ZipUtils.getEntryContentAsStream(blob.getStream(), IWORK_PREVIEW_FILE)) { previewBlob = Blobs.createBlob(previewPDFFile);
public static boolean hasEntry(URL url, String entryName) throws IOException { return hasEntry(url.openStream(), entryName); }
public static void zipFilesUsingPrefix(String prefix, File[] files, OutputStream out) throws IOException { try (ZipOutputStream zout = new ZipOutputStream(out)) { if (prefix != null && prefix.length() > 0) { int p = prefix.indexOf('/'); while (p > -1) { _putDirectoryEntry(prefix.substring(0, p), zout); p = prefix.indexOf(p + 1, '/'); } _putDirectoryEntry(prefix, zout); prefix += '/'; } else { prefix = ""; } // prefix = prefix + '/'; for (File file : files) { _putFileEntry(file, prefix + file.getName(), zout); } } }
public static void unzip(String prefix, URL zip, File dir) throws IOException { try (ZipInputStream in = new ZipInputStream(new BufferedInputStream(zip.openStream()))) { unzip(prefix, in, dir); } }
public static void _zip(File[] files, ZipOutputStream out, String prefix) throws IOException { String normalizedPrefix = normalizePrefix(prefix); for (File file : files) { String name = normalizedPrefix + file.getName(); _zip(name, file, out); } }
public static void unzip(InputStream zipStream, File dir) throws IOException { try (ZipInputStream in = new ZipInputStream(new BufferedInputStream(zipStream))) { unzip(in, dir); } }
public static void unzip(String prefix, ZipInputStream in, File dir, PathFilter filter) throws IOException { if (filter == null) { unzip(prefix, in, dir); } else { unzip(in, dir, toPredicate(filter).and(entry -> entry.getName().startsWith(prefix)), name -> name.substring(prefix.length())); } }
public static String getEntryContentAsString(InputStream stream, String searchedEntryName) throws IOException { try (InputStream resultStream = getEntryContentAsStream(stream, searchedEntryName)) { return IOUtils.toString(resultStream, UTF_8); } }
protected static void zip(List<Blob> blobs, ZipOutputStream out) throws IOException { // use a set to avoid zipping entries with same names Collection<String> names = new HashSet<String>(); int cnt = 1; for (Blob blob : blobs) { String entry = getFileName(blob); if (!names.add(entry)) { entry = "renamed_" + (cnt++) + "_" + entry; } InputStream in = blob.getStream(); try { ZipUtils._zip(entry, in, out); } finally { in.close(); } } }
public static void unzip(String prefix, InputStream zipStream, File dir) throws IOException { try (ZipInputStream in = new ZipInputStream(new BufferedInputStream(zipStream))) { unzip(prefix, in, dir); } }
public static byte[] getEntryContentAsBytes(URL url, String entryName) throws IOException { try (InputStream resultStream = getEntryContentAsStream(url, entryName)) { return IOUtils.toByteArray(resultStream); } }
public static void _putFileEntry(File file, String entryName, ZipOutputStream out) throws IOException { try (FileInputStream in = new FileInputStream(file)) { _zip(entryName, in, out); } }
public static void unzipIgnoreDirs(ZipInputStream in, File dir) throws IOException { unzip(in, dir, entry -> !entry.isDirectory(), Function.identity()); }
public static byte[] getEntryContentAsBytes(InputStream stream, String searchedEntryName) throws IOException { try (InputStream resultStream = getEntryContentAsStream(stream, searchedEntryName)) { return IOUtils.toByteArray(resultStream); } }
public static void zip(File[] files, OutputStream out, String prefix) throws IOException { try (ZipOutputStream zout = new ZipOutputStream(out)) { _zip(files, zout, prefix); } }