@Test public void write() throws IOException { final OutputStream throttled = new ThrottledOutputStream(this.out, 1000); final byte[] buf = new byte[100]; final long timestampStart = System.nanoTime(); throttled.write(buf); final long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - timestampStart); final long delta = Math.abs(duration - 100); assertThat(delta, lessThan(10L)); }
@Override public void write(final int b) throws IOException { super.write(b); throttle(1); }
ThrottledOutputStream extends FilterOutputStream { @Override public void write(final int b) throws IOException { super.write(b); throttle(1); } }
ThrottledOutputStream extends FilterOutputStream { @Override public void write(final int b) throws IOException { super.write(b); throttle(1); } ThrottledOutputStream(final OutputStream out, final long bytesPerSecond); }
ThrottledOutputStream extends FilterOutputStream { @Override public void write(final int b) throws IOException { super.write(b); throttle(1); } ThrottledOutputStream(final OutputStream out, final long bytesPerSecond); @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 String toString(); }
ThrottledOutputStream extends FilterOutputStream { @Override public void write(final int b) throws IOException { super.write(b); throttle(1); } ThrottledOutputStream(final OutputStream out, final long bytesPerSecond); @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 String toString();  }