public class BufferedStreamFeeder extends Object
| Constructor and Description |
|---|
BufferedStreamFeeder(InputStream is) |
BufferedStreamFeeder(InputStream is,
int bufsize) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this object.
|
int |
feed(IBytesConsumer consumer)
Feeds bytes to the consumer
Returns bytes actually consumed This should return 0 only if the stream is EOF or the consumer is done |
int |
feed(IBytesConsumer consumer,
int maxbytes)
Feeds the consumer (with at most maxbytes)
This should return 0 only if the stream is EOF or the consumer is done |
boolean |
feedFixed(IBytesConsumer consumer,
int nbytes)
Feeds exactly nbytes, retrying if necessary
|
InputStream |
getStream()
Returns inputstream
|
boolean |
hasMoreToFeed()
Returuns true if we have more data to fed the consumer.
|
boolean |
isEof() |
protected void |
refillBuffer()
If there are not pending bytes to be consumed tries to fill the buffer
with bytes from the stream.
|
void |
setCloseStream(boolean closeStream) |
void |
setFailIfNoFeed(boolean failIfNoFeed)
If this flag is set (default: false), any call to feed() that returns
zero (no byte feed) will throw an exception.
|
void |
setInputStream(InputStream is)
Sets a new underlying inputstream.
|
public BufferedStreamFeeder(InputStream is)
public BufferedStreamFeeder(InputStream is, int bufsize)
public InputStream getStream()
public int feed(IBytesConsumer consumer)
public int feed(IBytesConsumer consumer, int maxbytes)
public boolean feedFixed(IBytesConsumer consumer, int nbytes)
consumer - Consumernbytes - Number of bytesprotected void refillBuffer()
public boolean hasMoreToFeed()
public void setCloseStream(boolean closeStream)
closeStream - If true, the underlying stream will be closed on when close()
is calledpublic void close()
public void setInputStream(InputStream is)
is - public boolean isEof()
public void setFailIfNoFeed(boolean failIfNoFeed)
failIfNoFeed - Copyright © 2013. All rights reserved.