Package org.apache.commons.io.input
Class ThrottledInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.commons.io.input.ProxyInputStream
org.apache.commons.io.input.CountingInputStream
org.apache.commons.io.input.ThrottledInputStream
- All Implemented Interfaces:
- Closeable,- AutoCloseable
Provides bandwidth throttling on an InputStream as a filter input stream. The throttling examines the number of bytes read from the underlying InputStream,
 and sleeps for a time interval if the byte-transfer is found to exceed the specified maximum rate. Thus, while the read-rate might exceed the maximum for a
 short interval, the average tends towards the specified maximum, overall.
 
 To build an instance, call builder().
 
Inspired by Apache HBase's class of the same name.
- Since:
- 2.16.0
- See Also:
- 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from class org.apache.commons.io.input.ProxyInputStreamProxyInputStream.AbstractBuilder<T,B extends AbstractStreamBuilder<T, B>> 
- 
Field SummaryFields inherited from class java.io.FilterInputStreamin
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidbeforeRead(int n) Invoked by thereadmethods before the call is proxied.static ThrottledInputStream.Builderbuilder()Constructs a newThrottledInputStream.Builder.toString()Methods inherited from class org.apache.commons.io.input.CountingInputStreamafterRead, getByteCount, getCount, resetByteCount, resetCount, skipMethods inherited from class org.apache.commons.io.input.ProxyInputStreamavailable, close, handleIOException, mark, markSupported, read, read, read, reset, setReference, unwrap
- 
Method Details- 
builderConstructs a newThrottledInputStream.Builder.- Returns:
- a new ThrottledInputStream.Builder.
 
- 
beforeReadDescription copied from class:ProxyInputStreamInvoked by thereadmethods before the call is proxied. The number of bytes that the caller wanted to read (1 for theProxyInputStream.read()method, buffer length forProxyInputStream.read(byte[]), etc.) is given as an argument.Subclasses can override this method to add common pre-processing functionality without having to override all the read methods. The default implementation does nothing. Note this method is not called from ProxyInputStream.skip(long)orProxyInputStream.reset(). You need to explicitly override those methods if you want to add pre-processing steps also to them.- Overrides:
- beforeReadin class- ProxyInputStream
- Parameters:
- n- number of bytes that the caller asked to be read.
- Throws:
- IOException- if the pre-processing fails in a subclass.
 
- 
toString
 
-