public class RateLimitOutputStream extends OutputStream implements RateShaper
OutputStream with a limited rate of bytes. For a
description of blocking mode, see RateLimitInputStream.| Constructor and Description |
|---|
RateLimitOutputStream(OutputStream real,
TickSource tickSource,
int byteRate,
int prescale)
Constructs a byte-rate-limited
OutputStream. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
OutputStream |
getBaseStream()
Returns the underlying
OutputStream. |
int |
getByteRate()
Returns the bytes per tick (after prescaling) for this rate shaper.
|
int |
getPrescale()
Returns the current prescale value (ie.
|
TickSource |
getTickSource()
Returns the
TickSource this stream uses. |
void |
setByteRate(int bytesPerTick)
Sets a new byte rate per tick (after prescaling) for this rate shaper.
|
void |
setNonBlocking(boolean nonBlocking)
Sets the non-blocking flag.
|
void |
setPrescale(int prescale)
Sets a new prescale value (ie.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public RateLimitOutputStream(OutputStream real, TickSource tickSource, int byteRate, int prescale)
OutputStream. See
RateLimitInputStream for a description of the rate parameters
(byteRate and prescale).real - The raw OutputStream to send totickSource - The tick source to usebyteRate - The rate in bytes per tick (before prescaler) to useprescale - The prescaler to use (see RateLimitInputStream)public void setByteRate(int bytesPerTick)
RateShapersetByteRate in interface RateShaperbytesPerTick - the new byte rate per tick (after prescaling)public int getByteRate()
RateShapergetByteRate in interface RateShaperpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b)
throws IOException
write in class OutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void setNonBlocking(boolean nonBlocking)
nonBlocking - whether the stream should be in non-blocking mode (see
RateLimitInputStream).public int getPrescale()
RateShapergetPrescale in interface RateShaperpublic void setPrescale(int prescale)
RateShapersetPrescale in interface RateShaperprescale - the new prescalepublic OutputStream getBaseStream()
OutputStream.public TickSource getTickSource()
TickSource this stream uses.Copyright © 2015. All rights reserved.