Codota Logo
ZipUtil.iterate
Code IndexAdd Codota to your IDE (free)

How to use
iterate
method
in
org.zeroturnaround.zip.ZipUtil

Best Java code snippets using org.zeroturnaround.zip.ZipUtil.iterate (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: zeroturnaround/zt-zip

/**
 * See {@link #iterate(InputStream, ZipEntryCallback, Charset)}. This method
 * is a shorthand for a version where no Charset is specified.
 *
 * @param is
 *          input ZIP stream (it will not be closed automatically).
 * @param action
 *          action to be called for each entry.
 *
 * @see ZipEntryCallback
 * @see #iterate(File, ZipEntryCallback)
 */
public static void iterate(InputStream is, ZipEntryCallback action) {
 iterate(is, action, null);
}
origin: zeroturnaround/zt-zip

/**
 * Reads the given ZIP file and executes the given action for each entry.
 * <p>
 * For each entry the corresponding input stream is also passed to the action. If you want to stop the loop
 * then throw a ZipBreakException.
 *
 * @param zip
 *          input ZIP file.
 * @param action
 *          action to be called for each entry.
 *
 * @see ZipEntryCallback
 * @see #iterate(File, ZipInfoCallback)
 */
public static void iterate(File zip, ZipEntryCallback action) {
 iterate(zip, action, null);
}
origin: zeroturnaround/zt-zip

/**
 * See @link{ {@link #iterate(InputStream, ZipEntryCallback, Charset)}. It is a
 * shorthand where no Charset is specified.
 *
 * @param is
 *          input ZIP stream (it will not be closed automatically).
 * @param entryNames
 *          names of entries to iterate
 * @param action
 *          action to be called for each entry.
 *
 * @see ZipEntryCallback
 * @see #iterate(File, String[], ZipEntryCallback)
 */
public static void iterate(InputStream is, String[] entryNames, ZipEntryCallback action) {
 iterate(is, entryNames, action, null);
}
origin: zeroturnaround/zt-zip

/**
 * Reads the given ZIP file and executes the given action for each given entry.
 * <p>
 * For each given entry the corresponding input stream is also passed to the action. If you want to stop the loop then throw a ZipBreakException.
 *
 * @param zip
 *          input ZIP file.
 * @param entryNames
 *          names of entries to iterate
 * @param action
 *          action to be called for each entry.
 *
 * @see ZipEntryCallback
 * @see #iterate(File, String[], ZipInfoCallback)
 */
public static void iterate(File zip, String[] entryNames, ZipEntryCallback action) {
 iterate(zip, entryNames, action, null);
}
origin: zeroturnaround/zt-zip

/**
 * Copies all entries from one ZIP file to another.
 *
 * @param zip
 *          source ZIP file.
 * @param out
 *          target ZIP stream.
 */
private static void copyEntries(File zip, final ZipOutputStream out) {
 // this one doesn't call copyEntries with ignoredEntries, because that has poorer performance
 final Set<String> names = new HashSet<String>();
 iterate(zip, new ZipEntryCallback() {
  public void process(InputStream in, ZipEntry zipEntry) throws IOException {
   String entryName = zipEntry.getName();
   if (names.add(entryName)) {
    ZipEntryUtil.copyEntry(zipEntry, in, out);
   }
   else if (log.isDebugEnabled()) {
    log.debug("Duplicate entry: {}", entryName);
   }
  }
 });
}
origin: zeroturnaround/zt-zip

/**
 * Copies all entries from one ZIP stream to another.
 *
 * @param is
 *          source stream (contains ZIP file).
 * @param out
 *          target ZIP stream.
 */
private static void copyEntries(InputStream is, final ZipOutputStream out) {
 // this one doesn't call copyEntries with ignoredEntries, because that has poorer performance
 final Set<String> names = new HashSet<String>();
 iterate(is, new ZipEntryCallback() {
  public void process(InputStream in, ZipEntry zipEntry) throws IOException {
   String entryName = zipEntry.getName();
   if (names.add(entryName)) {
    ZipEntryUtil.copyEntry(zipEntry, in, out);
   }
   else if (log.isDebugEnabled()) {
    log.debug("Duplicate entry: {}", entryName);
   }
  }
 });
}
origin: jphp-group/jphp

@Signature
public void read(final Environment env, String path, final Invoker callback) {
  ZipUtil.iterate(zipFile, new String[]{path}, new ZipEntryCallback() {
    @Override
    public void process(InputStream in, ZipEntry zipEntry) throws IOException {
      callback.callAny(zipEntryToArray(zipEntry), new MiscStream(env, in));
    }
  });
}
origin: jphp-group/jphp

@Signature
public void readAll(final Environment env, final Invoker callback) {
  ZipUtil.iterate(zipFile, new ZipEntryCallback() {
    @Override
    public void process(InputStream in, ZipEntry zipEntry) throws IOException {
      callback.callAny(zipEntryToArray(zipEntry), new MiscStream(env, in));
    }
  });
}
origin: zeroturnaround/zt-zip

/**
 * Unwraps a ZIP file to the given directory shaving of root dir.
 * If there are multiple root dirs or entries in the root of zip,
 * ZipException is thrown.
 * <p>
 * The output directory must not be a file.
 *
 * @param zip
 *          input ZIP file.
 * @param outputDir
 *          output directory (created automatically if not found).
 * @param mapper
 *          call-back for renaming the entries.
 */
public static void unwrap(File zip, File outputDir, NameMapper mapper) {
 log.debug("Unwrapping '{}' into '{}'.", zip, outputDir);
 iterate(zip, new Unwrapper(outputDir, mapper));
}
origin: zeroturnaround/zt-zip

/**
 * Unwraps a ZIP file to the given directory shaving of root dir.
 * If there are multiple root dirs or entries in the root of zip,
 * ZipException is thrown.
 * <p>
 * The output directory must not be a file.
 *
 * @param is
 *          inputstream for ZIP file.
 * @param outputDir
 *          output directory (created automatically if not found).
 * @param mapper
 *          call-back for renaming the entries.
 */
public static void unwrap(InputStream is, File outputDir, NameMapper mapper) {
 log.debug("Unwrapping {} into '{}'.", is, outputDir);
 iterate(is, new Unwrapper(outputDir, mapper));
}
origin: zeroturnaround/zt-zip

/**
 * Unpacks a ZIP file to the given directory.
 * <p>
 * The output directory must not be a file.
 *
 * @param zip
 *          input ZIP file.
 * @param outputDir
 *          output directory (created automatically if not found).
 * @param mapper
 *          call-back for renaming the entries.
 * @param charset
 *          charset used to process the zip file
 */
public static void unpack(File zip, File outputDir, NameMapper mapper, Charset charset) {
 log.debug("Extracting '{}' into '{}'.", zip, outputDir);
 iterate(zip, new Unpacker(outputDir, mapper), charset);
}
origin: zeroturnaround/zt-zip

/**
 * Unpacks a ZIP stream to the given directory.
 * <p>
 * The output directory must not be a file.
 *
 * @param is
 *          inputstream for ZIP file.
 * @param outputDir
 *          output directory (created automatically if not found).
 * @param mapper
 *          call-back for renaming the entries.
 * @param charset
 *          charset to use when unpacking the stream
 */
public static void unpack(InputStream is, File outputDir, NameMapper mapper, Charset charset) {
 log.debug("Extracting {} into '{}'.", is, outputDir);
 iterate(is, new Unpacker(outputDir, mapper), charset);
}
origin: zeroturnaround/zt-zip

/**
 * Unpacks a ZIP file to the given directory using a specific Charset
 * for the input file.
 *
 * <p>
 * The output directory must not be a file.
 *
 * @param zip
 *          input ZIP file.
 * @param outputDir
 *          output directory (created automatically if not found).
 * @param mapper
 *          call-back for renaming the entries.
 */
public static void unpack(File zip, File outputDir, NameMapper mapper) {
 log.debug("Extracting '{}' into '{}'.", zip, outputDir);
 iterate(zip, new Unpacker(outputDir, mapper));
}
origin: zeroturnaround/zt-zip

/**
 * Repacks a provided ZIP input stream into a ZIP file with a given compression level.
 * <p>
 *
 * @param is
 *          ZIP input stream.
 * @param dstZip
 *          destination ZIP file.
 * @param compressionLevel
 *          compression level.
 */
public static void repack(InputStream is, File dstZip, int compressionLevel) {
 log.debug("Repacking from input stream into '{}'.", dstZip);
 RepackZipEntryCallback callback = new RepackZipEntryCallback(dstZip, compressionLevel);
 try {
  iterate(is, callback);
 }
 finally {
  callback.closeStream();
 }
}
origin: zeroturnaround/zt-zip

/**
 * Repacks a provided ZIP file into a new ZIP with a given compression level.
 * <p>
 *
 * @param srcZip
 *          source ZIP file.
 * @param dstZip
 *          destination ZIP file.
 * @param compressionLevel
 *          compression level.
 */
public static void repack(File srcZip, File dstZip, int compressionLevel) {
 log.debug("Repacking '{}' into '{}'.", srcZip, dstZip);
 RepackZipEntryCallback callback = new RepackZipEntryCallback(dstZip, compressionLevel);
 try {
  iterate(srcZip, callback);
 }
 finally {
  callback.closeStream();
 }
}
origin: jphp-group/jphp

@Signature
public Memory stat(String path) {
  final ArrayMemory[] result = new ArrayMemory[1];
  ZipUtil.iterate(zipFile, new String[] { path }, new ZipInfoCallback() {
    @Override
    public void process(ZipEntry zipEntry) throws IOException {
      result[0] = zipEntryToArray(zipEntry);
    }
  });
  return result[0].toConstant();
}
origin: zeroturnaround/zt-zip

/**
 * Copies an existing ZIP file and transforms the given entries in it.
 *
 * @param zip
 *          an existing ZIP file (only read).
 * @param entries
 *          ZIP entry transformers.
 * @param destZip
 *          new ZIP file created.
 * @return <code>true</code> if at least one entry was replaced.
 */
public static boolean transformEntries(File zip, ZipEntryTransformerEntry[] entries, File destZip) {
 if (log.isDebugEnabled())
  log.debug("Copying '" + zip + "' to '" + destZip + "' and transforming entries " + Arrays.asList(entries) + ".");
 try {
  ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destZip)));
  try {
   TransformerZipEntryCallback action = new TransformerZipEntryCallback(Arrays.asList(entries), out);
   iterate(zip, action);
   return action.found();
  }
  finally {
   IOUtils.closeQuietly(out);
  }
 }
 catch (IOException e) {
  throw ZipExceptionUtil.rethrow(e);
 }
}
origin: zeroturnaround/zt-zip

/**
 * Reads the given ZIP stream and executes the given action for a single
 * entry.
 *
 * @param is
 *          input ZIP stream (it will not be closed automatically).
 * @param name
 *          entry name.
 * @param action
 *          action to be called for this entry.
 * @return <code>true</code> if the entry was found, <code>false</code> if the
 *         entry was not found.
 *
 * @see ZipEntryCallback
 */
public static boolean handle(InputStream is, String name, ZipEntryCallback action) {
 SingleZipEntryCallback helper = new SingleZipEntryCallback(name, action);
 iterate(is, helper);
 return helper.found();
}
origin: jphp-group/jphp

@Signature
public Memory statAll() {
  final ArrayMemory result = new ArrayMemory();
  ZipUtil.iterate(zipFile, new ZipInfoCallback() {
    @Override
    public void process(ZipEntry zipEntry) throws IOException {
      result.put(zipEntry.getName(), zipEntryToArray(zipEntry));
    }
  });
  return result.toConstant();
}
origin: zeroturnaround/zt-zip

/**
 * Copies an existing ZIP file and transforms the given entries in it.
 *
 * @param is
 *          a ZIP input stream.
 * @param entries
 *          ZIP entry transformers.
 * @param os
 *          a ZIP output stream.
 * @return <code>true</code> if at least one entry was replaced.
 */
public static boolean transformEntries(InputStream is, ZipEntryTransformerEntry[] entries, OutputStream os) {
 if (log.isDebugEnabled())
  log.debug("Copying '" + is + "' to '" + os + "' and transforming entries " + Arrays.asList(entries) + ".");
 try {
  ZipOutputStream out = new ZipOutputStream(os);
  TransformerZipEntryCallback action = new TransformerZipEntryCallback(Arrays.asList(entries), out);
  iterate(is, action);
  // Finishes writing the contents of the ZIP output stream without closing
  // the underlying stream.
  out.finish();
  return action.found();
 }
 catch (IOException e) {
  throw ZipExceptionUtil.rethrow(e);
 }
}
org.zeroturnaround.zipZipUtiliterate

Javadoc

Reads the given ZIP file and executes the given action for each entry.

For each entry the corresponding input stream is also passed to the action. If you want to stop the loop then throw a ZipBreakException.

Popular methods of ZipUtil

  • pack
  • unpack
    Unpacks a ZIP stream to the given directory. The output directory must not be a file.
  • unpackEntry
    Unpacks a single file from a ZIP archive to a file.
  • removeEntry
    Copies an existing ZIP file and removes entry with a given path.
  • containsEntry
    Checks if the ZIP file contains the given entry.
  • addOrReplaceEntries
    Copies an existing ZIP file and adds/replaces the given entries in it.
  • packEntries
    Compresses the given files into a ZIP file. The ZIP file must not be a directory and its parent dire
  • removeEntries
    Copies an existing ZIP file and removes entries with given paths.
  • repack
    Repacks a provided ZIP input stream into a ZIP file with a given compression level.
  • replaceEntry
    Copies an existing ZIP file and replaces a given entry in it.
  • unexplode
    Compresses a given directory in its own location. A ZIP file will be first created with a temporary
  • unwrap
    Unwraps a ZIP file to the given directory shaving of root dir. If there are multiple root dirs or en
  • unexplode,
  • unwrap,
  • addEntries,
  • addEntry,
  • archiveEqualsInternal,
  • checkDestinationFileForTraversal,
  • closeQuietly,
  • copyEntries,
  • doEntryEquals

Popular in Java

  • Updating database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • notifyDataSetChanged (ArrayAdapter)
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Socket (java.net)
    Provides a client-side TCP socket.
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now