List of usage examples for org.apache.commons.io.output ByteArrayOutputStream ByteArrayOutputStream
public ByteArrayOutputStream(int size)
From source file:ch.cyberduck.core.io.MemorySegementingOutputStreamTest.java
@Test public void testCopy1() throws Exception { final ByteArrayOutputStream proxy = new ByteArrayOutputStream(20); final MemorySegementingOutputStream out = new MemorySegementingOutputStream(proxy, 32768); final byte[] content = RandomUtils.nextBytes(40500); out.write(content, 0, 32800);//from w w w .j av a 2s . co m assertEquals(32768, proxy.toByteArray().length); out.write(content, 32800, 7700); out.close(); assertArrayEquals(content, proxy.toByteArray()); }
From source file:com.yahoo.parsec.web.ParsecServletRequestWrapper.java
/** * Constructs a request object wrapping the given request. * * @param request servlet request/*from w w w. j a v a 2 s .com*/ */ public ParsecServletRequestWrapper(HttpServletRequest request) { super(request); int contentLength = request.getContentLength(); contentStream = new ByteArrayOutputStream(contentLength >= 0 ? contentLength : 1024); }
From source file:net.larry1123.elec.util.io.ProxyOutputSteam.java
public ProxyOutputSteam(OutputStream outputStream) { super(512); memoryOutputStream = new ByteArrayOutputStream(512); out = outputStream; }
From source file:eu.matejkormuth.rpgdavid.starving.npc.util.NullSocket.java
@Override public OutputStream getOutputStream() throws IOException { return new ByteArrayOutputStream(64); }
From source file:ch.cyberduck.core.io.MemorySegementingOutputStreamTest.java
@Test public void testCopy2() throws Exception { final ByteArrayOutputStream proxy = new ByteArrayOutputStream(40500); final MemorySegementingOutputStream out = new MemorySegementingOutputStream(proxy, 32768); final byte[] content = RandomUtils.nextBytes(40500); out.write(content, 0, 32768);// ww w.ja va 2 s .com out.write(content, 32768, 7732); out.close(); assertArrayEquals(content, proxy.toByteArray()); }
From source file:io.digibyte.tools.util.BRCompressor.java
public static byte[] gZipCompress(byte[] data) { if (data == null) return null; byte[] compressedData = null; try {//w w w .j av a 2 s. c o m ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length); try { GZIPOutputStream zipStream = new GZIPOutputStream(byteStream); try { zipStream.write(data); } finally { try { zipStream.close(); } catch (IOException e) { e.printStackTrace(); } } } finally { try { byteStream.close(); } catch (IOException e) { e.printStackTrace(); } } compressedData = byteStream.toByteArray(); } catch (Exception e) { BRReportsManager.reportBug(e); e.printStackTrace(); } return compressedData; }
From source file:co.runrightfast.vertx.core.hazelcast.serializers.CompressedJsonObjectSerializer.java
@Override public byte[] write(final JsonObject json) throws IOException { final byte[] bytes = json.toString().getBytes(UTF_8); final ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); try (final GZIPOutputStream gzip = new GZIPOutputStream(bos)) { gzip.write(bytes);//from www . j a va 2s. c o m } return bos.toByteArray(); }
From source file:net.larry1123.elec.util.io.ProxyOutputSteam.java
@Override public void close() throws IOException { drainMemoryOutputSteam(); out.close(); out = new ByteArrayOutputStream(512); }
From source file:com.breadwallet.tools.util.BRCompressor.java
public static byte[] gZipCompress(byte[] data) { if (data == null) return null; byte[] compressedData = null; try {//from w w w .ja v a2 s.com ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length); try { GZIPOutputStream zipStream = new GZIPOutputStream(byteStream); try { zipStream.write(data); } finally { try { zipStream.close(); } catch (IOException e) { e.printStackTrace(); } } } finally { try { byteStream.close(); } catch (IOException e) { e.printStackTrace(); } } compressedData = byteStream.toByteArray(); } catch (Exception e) { FirebaseCrash.report(e); e.printStackTrace(); } return compressedData; }
From source file:hudson.util.HeadBufferingStream.java
public HeadBufferingStream(InputStream in, int sideBufferSize) { super(in);/*from w w w . j ava 2 s . c om*/ this.sideBufferSize = sideBufferSize; this.side = new ByteArrayOutputStream(sideBufferSize); }