public static class ThrottledInputStream.Builder extends AbstractStreamBuilder<ThrottledInputStream,ThrottledInputStream.Builder>
ThrottledInputStream.
ThrottledInputStream in = ThrottledInputStream.builder()
.setPath(Paths.get("MyFile.xml"))
.setMaxBytesPerSecond(100_000)
.get();
ThrottledInputStream in = ThrottledInputStream.builder()
.setFile(new File("MyFile.xml"))
.setMaxBytesPerSecond(100_000)
.get();
ThrottledInputStream in = ThrottledInputStream.builder()
.setInputStream(inputStream)
.setMaxBytesPerSecond(100_000)
.get();
get()| Modifier and Type | Field and Description |
|---|---|
private long |
maxBytesPerSecond
Effectively not throttled.
|
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
ThrottledInputStream |
get()
Builds a new
ThrottledInputStream. |
void |
setMaxBytesPerSecond(long maxBytesPerSecond)
Sets the maximum bytes per second.
|
getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getInputStream, getOpenOptions, getOutputStream, getPath, getReader, getWriter, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeDefault, setBufferSizeMax, setCharset, setCharset, setCharsetDefault, setOpenOptionscheckOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOrigin, setOutputStream, setPath, setPath, setReader, setURI, setWriterasThisclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasSupplierpublic ThrottledInputStream get() throws java.io.IOException
ThrottledInputStream.
You must set input that supports AbstractStreamBuilder.getInputStream(), otherwise, this method throws an exception.
This builder use the following aspects:
AbstractStreamBuilder.getInputStream()java.lang.IllegalStateException - if the origin is null.java.lang.UnsupportedOperationException - if the origin cannot be converted to an InputStream.java.io.IOException - if an I/O error occurs.AbstractStreamBuilder.getInputStream()public void setMaxBytesPerSecond(long maxBytesPerSecond)
maxBytesPerSecond - the maximum bytes per second.