/** * {@inheritDoc} */ @Override public void writeTo(final OutputStream outputStream, final Formatter formatter) throws IllegalArgumentException { try { IOUtil.bufferedWriteWithFlush(outputStream, toString(formatter).getBytes()); } catch (IOException ioe) { throw new IllegalArgumentException("Could not write Archive contents to specified OutputStream", ioe); } }
/** * {@inheritDoc} */ @Override public void writeTo(final OutputStream outputStream, final Formatter formatter) throws IllegalArgumentException { try { IOUtil.bufferedWriteWithFlush(outputStream, toString(formatter).getBytes()); } catch (IOException ioe) { throw new IllegalArgumentException("Could not write Archive contents to specified OutputStream", ioe); } }
@Test public void shouldBufferWritesCorrectly() throws IOException { MockOutputStream outputStream = new MockOutputStream(); byte[] content = new byte[9202]; for (int i = 0; i < content.length; i++) { content[i] = (i + "").getBytes()[0]; } IOUtil.bufferedWriteWithFlush(outputStream, content); Assert.assertArrayEquals("Inconsistent writes?", content, outputStream.getContents()); }