public static byte[] read(InputStream in) throws IOException { return copy(in, new ByteBufferOutputStream()).toByteArray(); }
@Override public void write(byte[] b) { int len = b.length; bb(len).put(b, 0, len); }
private ByteBuffer getBuffer() throws Exception { if (buffer != null) { return buffer; } ByteBufferOutputStream out = new ByteBufferOutputStream(); write(out); return buffer = out.toByteBuffer(); }
public void write(InputStream in) throws IOException { if (in instanceof ByteBufferInputStream) { ByteBufferInputStream bbin = (ByteBufferInputStream) in; write(bbin.buffer()); return; } ByteBuffer obb; do { obb = bb(in.available() + 1); byte[] buffer = obb.array(); for (int size, position; obb.hasRemaining() && (size = in.read(buffer, position = obb.position(), obb.remaining())) > 0;) { obb.position(position + size); } } while (!obb.hasRemaining()); }
private Jar buildFromInputStream(InputStream in, long lastModified) throws IOException { try (ZipInputStream jin = new ZipInputStream(in)) { for (ZipEntry entry; (entry = jin.getNextEntry()) != null;) { if (entry.isDirectory()) { continue; } int size = (int) entry.getSize(); try (ByteBufferOutputStream bbos = new ByteBufferOutputStream((size == -1) ? BUFFER_SIZE : size + 1)) { bbos.write(jin); putResource(entry.getName(), new EmbeddedResource(bbos.toByteBuffer(), lastModified), true); } } } return this; }
try (ByteBufferOutputStream o = new ByteBufferOutputStream()) { Manifest manifest = jar.getManifest(); manifest.getMainAttributes() o.flush(); byte newManifestBytes[] = o.toByteArray(); jar.putResource("META-INF/MANIFEST.MF", new EmbeddedResource(newManifestBytes, 0L)); try (ByteBufferOutputStream tmpStream = new ByteBufferOutputStream()) { jar.putResource("META-INF/BND.RSA", new EmbeddedResource(tmpStream.toByteArray(), 0L));
public byte[] toByteArray() { ByteBuffer obb = toByteBuffer(); int len = obb.remaining(); byte[] result = new byte[len]; obb.get(result, 0, len); return result; }
public static ByteBufferOutputStream copy(InputStream in, ByteBufferOutputStream out) throws IOException { try { out.write(in); return out; } finally { in.close(); } }
public void write(InputStream in) throws IOException { if (in instanceof ByteBufferInputStream) { ByteBufferInputStream bbin = (ByteBufferInputStream) in; write(bbin.buffer()); return; } ByteBuffer obb; do { obb = bb(in.available() + 1); byte[] buffer = obb.array(); for (int size, position; obb.hasRemaining() && (size = in.read(buffer, position = obb.position(), obb.remaining())) > 0;) { obb.position(position + size); } } while (!obb.hasRemaining()); }
private Jar buildFromInputStream(InputStream in, long lastModified) throws IOException { try (ZipInputStream jin = new ZipInputStream(in)) { for (ZipEntry entry; (entry = jin.getNextEntry()) != null;) { if (entry.isDirectory()) { continue; } int size = (int) entry.getSize(); try (ByteBufferOutputStream bbos = new ByteBufferOutputStream((size == -1) ? BUFFER_SIZE : size + 1)) { bbos.write(jin); putResource(entry.getName(), new EmbeddedResource(bbos.toByteBuffer(), lastModified), true); } } } return this; }
try (ByteBufferOutputStream o = new ByteBufferOutputStream()) { Manifest manifest = jar.getManifest(); manifest.getMainAttributes() o.flush(); byte newManifestBytes[] = o.toByteArray(); jar.putResource("META-INF/MANIFEST.MF", new EmbeddedResource(newManifestBytes, 0L)); try (ByteBufferOutputStream tmpStream = new ByteBufferOutputStream()) { jar.putResource("META-INF/BND.RSA", new EmbeddedResource(tmpStream.toByteArray(), 0L));
public byte[] toByteArray() { ByteBuffer obb = toByteBuffer(); int len = obb.remaining(); byte[] result = new byte[len]; obb.get(result, 0, len); return result; }
public static ByteBufferOutputStream copy(InputStream in, ByteBufferOutputStream out) throws IOException { try { out.write(in); return out; } finally { in.close(); } }
public static byte[] read(InputStream in) throws IOException { return copy(in, new ByteBufferOutputStream()).toByteArray(); }
@Override public void write(byte[] b) { int len = b.length; bb(len).put(b, 0, len); }
public void write(InputStream in) throws IOException { if (in instanceof ByteBufferInputStream) { ByteBufferInputStream bbin = (ByteBufferInputStream) in; write(bbin.buffer()); return; } ByteBuffer obb; do { obb = bb(in.available() + 1); byte[] buffer = obb.array(); for (int size, position; obb.hasRemaining() && (size = in.read(buffer, position = obb.position(), obb.remaining())) > 0;) { obb.position(position + size); } } while (!obb.hasRemaining()); }
private ByteBuffer getBuffer() throws Exception { if (buffer != null) { return buffer; } ByteBufferOutputStream out = new ByteBufferOutputStream(); write(out); return buffer = out.toByteBuffer(); }
public byte[] toByteArray() { ByteBuffer obb = toByteBuffer(); int len = obb.remaining(); byte[] result = new byte[len]; obb.get(result, 0, len); return result; }
public static ByteBufferOutputStream copy(InputStream in, ByteBufferOutputStream out) throws IOException { try { out.write(in); return out; } finally { in.close(); } }
public static byte[] read(InputStream in) throws IOException { return copy(in, new ByteBufferOutputStream()).toByteArray(); }