/** * Creates a new JarWriter. * @param header an optional header for the jar file. * @param dataEntryWriter the data entry writer that can provide * output streams for the jar/zip archives. */ public JarWriter(byte[] header, DataEntryWriter dataEntryWriter) { this(header, currentTime(), dataEntryWriter); }
public void close() throws IOException { finish(); // Close the delegate writer. dataEntryWriter.close(); }
public OutputStream createOutputStream(DataEntry dataEntry) throws IOException { finishIfNecessary(dataEntry); setUp(dataEntry); // Did we get a zip output? if (currentZipOutput == null) { return null; } // Create a new zip entry. return currentZipOutput.createOutputStream(dataEntry.getName(), true, modificationTime); }
public boolean createDirectory(DataEntry dataEntry) throws IOException { //Make sure we can start with a new entry. if (!prepareEntry(dataEntry)) { return false; } // Close the previous ZIP entry, if any. closeEntry(); // Get the directory entry name. String name = dataEntry.getName() + ClassConstants.INTERNAL_PACKAGE_SEPARATOR; // We have to check if the name is already used, because // ZipOutputStream doesn't handle this case properly (it throws // an exception which can be caught, but the ZipDataEntry is // remembered anyway). if (jarEntryNames.add(name)) { // Create a new directory entry. currentJarOutputStream.putNextEntry(new ZipEntry(name)); currentJarOutputStream.closeEntry(); } // Clear the finisher. currentFinisher = null; currentDataEntry = null; return true; }
public OutputStream getOutputStream(DataEntry dataEntry) throws IOException { return getOutputStream(dataEntry, null); }
public void finish() throws IOException { // Finish the entire ZIP stream, if any. if (currentJarOutputStream != null) { // Close the previous ZIP entry, if any. closeEntry(); // Finish the entire ZIP stream. currentJarOutputStream.finish(); currentJarOutputStream = null; currentParentOutputStream = null; jarEntryNames.clear(); } }
DataEntryWriter zipWriter = new JarWriter(writer); if (outputIsZip) DataEntryWriter jmodWriter = new JarWriter(ClassConstants.JMOD_HEADER, writer); if (outputIsJmod) DataEntryWriter warWriter = new JarWriter(writer); if (outputIsWar) DataEntryWriter aarWriter = new JarWriter(writer); if (outputIsWar) DataEntryWriter jarWriter = new JarWriter(writer); if (outputIsJar) DataEntryWriter apkWriter = new JarWriter(writer); if (outputIsApk)
if (!prepareEntry(dataEntry)) closeEntry();
public OutputStream createOutputStream(DataEntry dataEntry) throws IOException { finishIfNecessary(dataEntry); setUp(dataEntry); // Did we get a zip output? if (currentZipOutput == null) { return null; } // Create a new zip entry. return currentZipOutput.createOutputStream(dataEntry.getName(), true, modificationTime); }
DataEntryWriter zipWriter = new JarWriter(writer); if (outputIsZip) DataEntryWriter jmodWriter = new JarWriter(ClassConstants.JMOD_HEADER, writer); if (outputIsJmod) DataEntryWriter warWriter = new JarWriter(writer); if (outputIsWar) DataEntryWriter aarWriter = new JarWriter(writer); if (outputIsWar) DataEntryWriter jarWriter = new JarWriter(writer); if (outputIsJar) DataEntryWriter apkWriter = new JarWriter(writer); if (outputIsApk)
public void close() throws IOException { finish(); // Close the delegate writer. dataEntryWriter.close(); }
/** * Creates a new JarWriter. * @param header an optional header for the jar file. * @param dataEntryWriter the data entry writer that can provide * output streams for the jar/zip archives. */ public JarWriter(byte[] header, DataEntryWriter dataEntryWriter) { this(header, currentTime(), dataEntryWriter); }
public OutputStream createOutputStream(DataEntry dataEntry) throws IOException { finishIfNecessary(dataEntry); setUp(dataEntry); // Did we get a zip output? if (currentZipOutput == null) { return null; } // Create a new zip entry. return currentZipOutput.createOutputStream(dataEntry.getName(), true, modificationTime); }
DataEntryWriter zipWriter = new JarWriter(writer); if (outputIsZip) DataEntryWriter jmodWriter = new JarWriter(ClassConstants.JMOD_HEADER, writer); if (outputIsJmod) DataEntryWriter warWriter = new JarWriter(writer); if (outputIsWar) DataEntryWriter aarWriter = new JarWriter(writer); if (outputIsWar) DataEntryWriter jarWriter = new JarWriter(writer); if (outputIsJar) DataEntryWriter apkWriter = new JarWriter(writer); if (outputIsApk)
public void close() throws IOException { finish(); // Close the delegate writer. dataEntryWriter.close(); }
/** * Creates a new JarWriter. * @param header an optional header for the jar file. * @param dataEntryWriter the data entry writer that can provide * output streams for the jar/zip archives. */ public JarWriter(byte[] header, DataEntryWriter dataEntryWriter) { this(header, currentTime(), dataEntryWriter); }
public boolean createDirectory(DataEntry dataEntry) throws IOException { finishIfNecessary(dataEntry); setUp(dataEntry); // Did we get a zip output? if (currentZipOutput == null) { return false; } // Get the directory entry name. String name = dataEntry.getName() + ClassConstants.PACKAGE_SEPARATOR; // Create a new directory entry. OutputStream outputStream = currentZipOutput.createOutputStream(name, false, modificationTime); outputStream.close(); return true; }
/** * Wraps the given DataEntryWriter in a JarWriter, filtering if necessary. */ private static DataEntryWriter wrapInJarWriter(DataEntryWriter writer, boolean isJar, List jarFilter, String jarExtension, boolean dontWrap) { // Zip up jars, if necessary. DataEntryWriter jarWriter = dontWrap ? (DataEntryWriter)new ParentDataEntryWriter(writer) : (DataEntryWriter)new JarWriter(writer); // Add a filter, if specified. DataEntryWriter filteredJarWriter = jarFilter != null? new FilteredDataEntryWriter( new DataEntryParentFilter( new DataEntryNameFilter( new ListParser(new FileNameParser()).parse(jarFilter))), jarWriter) : jarWriter; // Only zip up jars, unless the output is a jar file itself. return new FilteredDataEntryWriter( new DataEntryParentFilter( new DataEntryNameFilter( new ExtensionMatcher(jarExtension))), filteredJarWriter, isJar ? jarWriter : writer); }
private void finishIfNecessary(DataEntry dataEntry) throws IOException { // Would the new data entry end up in a different jar? if (currentParentEntry != null && !dataEntryWriter.sameOutputStream(currentParentEntry, dataEntry.getParent())) { finish(); } }