@Test public void testSetByteCount() throws Exception { final AtomicBoolean reached = new AtomicBoolean(false); ThresholdingOutputStream tos = new ThresholdingOutputStream(3) { { setByteCount(2); } @Override protected OutputStream getStream() throws IOException { return new ByteArrayOutputStream(4); } @Override protected void thresholdReached() throws IOException { reached.set( true); } }; tos.write(12); assertFalse( reached.get()); tos.write(12); assertTrue(reached.get()); tos.close(); }
protected void setByteCount(final long count) { this.written = count; }
ThresholdingOutputStream extends OutputStream { protected void setByteCount(final long count) { this.written = count; } }
ThresholdingOutputStream extends OutputStream { protected void setByteCount(final long count) { this.written = count; } ThresholdingOutputStream(final int threshold); }
ThresholdingOutputStream extends OutputStream { protected void setByteCount(final long count) { this.written = count; } ThresholdingOutputStream(final int threshold); @Override void write(final int b); @Override void write(final byte b[]); @Override void write(final byte b[], final int off, final int len); @Override void flush(); @Override void close(); int getThreshold(); long getByteCount(); boolean isThresholdExceeded(); }
ThresholdingOutputStream extends OutputStream { protected void setByteCount(final long count) { this.written = count; } ThresholdingOutputStream(final int threshold); @Override void write(final int b); @Override void write(final byte b[]); @Override void write(final byte b[], final int off, final int len); @Override void flush(); @Override void close(); int getThreshold(); long getByteCount(); boolean isThresholdExceeded();  }