out.write(buffer, 0, num); out.flush();
/** * Finalizes the packing process and thus the written JAR file. * @throws IOException Thrown if an error occurs while finalizing the JAR. */ public void close() throws IOException { jarStream.flush(); jarStream.close(); } }
void transferContents(InputStream fin, JarOutputStream jos) throws IOException { if (fin == null || jos == null) { return; } int read = 0; byte[] buffer = new byte[8192]; while ((read = fin.read(buffer, 0, buffer.length)) != -1) { jos.write(buffer, 0, read); } jos.flush(); }
void transferContents(InputStream fin, JarOutputStream jos) throws IOException { if (fin == null || jos == null) { return; } int read = 0; byte[] buffer = new byte[8192]; while ((read = fin.read(buffer, 0, buffer.length)) != -1) { jos.write(buffer, 0, read); } jos.flush(); }
void transferContents(InputStream fin, JarOutputStream jos) throws IOException { if (fin == null || jos == null) { return; } int read = 0; byte[] buffer = new byte[8192]; while ((read = fin.read(buffer, 0, buffer.length)) != -1) { jos.write(buffer, 0, read); } jos.flush(); }
@Override public void modifyOutputStream(JarOutputStream os) throws IOException { os.putNextEntry(new JarEntry(this.resource)); this.data.store(os, "Merged by PropertiesMergingResourceTransformer"); os.flush(); this.data.clear(); }
private static void addEntry(JarOutputStream jarOut, String path, byte[] data) throws IOException { jarOut.putNextEntry(new JarEntry(path)); jarOut.write(data); jarOut.flush(); jarOut.closeEntry(); } //</editor-fold>
private void init(Manifest man, Iterator<ArtifactData> iter, boolean fixPack) throws IOException { m_max = 0; m_pos = 0; m_output = new JarOutputStream(m_outputBuffer, man); m_output.flush(); m_iter = iter; m_fixPack = fixPack; next(); }
private void writeManifest(JarOutputStream out, BundleManifest manifest) throws IOException { out.putNextEntry(new JarEntry("META-INF/")); out.write(new byte[0]); out.flush(); out.closeEntry(); out.putNextEntry(new JarEntry(JarFile.MANIFEST_NAME)); Writer writer = new NonClosingOuptutStreamWriter(out); manifest.write(writer); writer.flush(); out.flush(); out.closeEntry(); }
static InputStream getSurrogateInput(Dictionary compositeManifest, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) throws IOException { // use an in memory stream to store the content ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); Manifest manifest = CompositeHelper.getSurrogateManifest(compositeManifest, compositeDesc, matchingExports); JarOutputStream jarOut = new JarOutputStream(bytesOut, manifest); jarOut.flush(); jarOut.close(); return new ByteArrayInputStream(bytesOut.toByteArray()); }
public static File createJarWithClassPath(File file, String mainClassName, String... classPath) throws IOException { JarOutputStream jarOut = new JarOutputStream( new FileOutputStream(file), createManifest(MANIFEST_VERSION, mainClassName, classPath) ); jarOut.flush(); jarOut.close(); return file; }
private void writeManifest(JarOutputStream out, BundleManifest manifest) throws IOException { out.putNextEntry(new JarEntry("META-INF/")); out.write(new byte[0]); out.flush(); out.closeEntry(); out.putNextEntry(new JarEntry(JarFile.MANIFEST_NAME)); Writer writer = new NonClosingOuptutStreamWriter(out); manifest.write(writer); writer.flush(); out.flush(); out.closeEntry(); }
static InputStream getSurrogateInput(Dictionary compositeManifest, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) throws IOException { // use an in memory stream to store the content ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); Manifest manifest = CompositeHelper.getSurrogateManifest(compositeManifest, compositeDesc, matchingExports); JarOutputStream jarOut = new JarOutputStream(bytesOut, manifest); jarOut.flush(); jarOut.close(); return new ByteArrayInputStream(bytesOut.toByteArray()); }
protected void copy(JarFile in, JarEntry je, JarOutputStream jos) throws IOException { try { jos.putNextEntry(new JarEntry(je.getName())); copy(in, je, (OutputStream) jos); } finally { jos.flush(); jos.closeEntry(); } }
protected void copy(JarFile in, JarEntry je, JarOutputStream jos) throws IOException { try { jos.putNextEntry(new JarEntry(je.getName())); copy(in, je, (OutputStream) jos); } finally { jos.flush(); jos.closeEntry(); } }
public static byte[] generateJar(Map<String, byte[]> resources) throws IOException { if (resources == null || resources.size() == 0) { throw new IOException("No Resources available"); } final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final JarOutputStream out = new JarOutputStream(new BufferedOutputStream(baos)); for (Map.Entry<String, byte[]> resource : resources.entrySet()) { out.putNextEntry(new JarEntry(resource.getKey())); out.write(resource.getValue()); } out.flush(); Misc.close(out); return baos.toByteArray(); }
public static byte[] generateJar(final Map<String, byte[]> resources) throws IOException { if (resources == null || resources.size() == 0) { throw new IOException("No Resources available"); } final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final JarOutputStream out = new JarOutputStream(new BufferedOutputStream(baos)); for (final Map.Entry<String, byte[]> resource : resources.entrySet()) { out.putNextEntry(new JarEntry(resource.getKey())); out.write(resource.getValue()); } out.flush(); Misc.close(out); return baos.toByteArray(); }
public MemoryMappedArchive(ReadableArchive source) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JarOutputStream jos = new JarOutputStream(baos); for (Enumeration elements = source.entries();elements.hasMoreElements();) { String elementName = (String) elements.nextElement(); InputStream is = source.getEntry(elementName); jos.putNextEntry(new ZipEntry(elementName)); ArchivistUtils.copyWithoutClose(is, jos); is.close(); jos.flush(); jos.closeEntry(); } jos.close(); file = baos.toByteArray(); }