|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream com.healthmarketscience.rmiio.PacketInputStream
public abstract class PacketInputStream
Adds support for packet based access to data from an InputStream. Can be more efficient for certain stream implementations, especially for remote stream usage where data is coming across the wire in byte[] packets.
Field Summary | |
---|---|
static int |
DEFAULT_PACKET_SIZE
target size of packets returned from packet related methods |
protected static byte[] |
EMPTY_PACKET
empty packet. |
Constructor Summary | |
---|---|
PacketInputStream()
|
|
PacketInputStream(int packetSize)
|
|
PacketInputStream(int packetSize,
boolean noDelay)
|
Method Summary | |
---|---|
boolean |
getNoDelay()
|
int |
getPacketSize()
|
abstract int |
packetsAvailable()
Returns the number of full packets which can be read without blocking. |
byte[] |
readPacket()
Gets the next "packet" from the internal buffer and returns it (if any). |
abstract byte[] |
readPacket(boolean readPartial)
Gets the next "packet" from the internal buffer and returns it (if any). |
static byte[] |
readPacket(InputStream in,
byte[] packet)
Reads a packet of data from the given input stream. |
Methods inherited from class java.io.InputStream |
---|
available, close, mark, markSupported, read, read, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PACKET_SIZE
protected static final byte[] EMPTY_PACKET
Constructor Detail |
---|
public PacketInputStream()
public PacketInputStream(int packetSize)
public PacketInputStream(int packetSize, boolean noDelay)
Method Detail |
---|
public int getPacketSize()
public boolean getNoDelay()
public byte[] readPacket() throws IOException
readPacket(false)
). If noDelay is
enabled, this method will allow partial packet reads (equivalent to
calling readPacket(true)
).
null
if the end of
stream has been reached
IOException
public abstract byte[] readPacket(boolean readPartial) throws IOException
readPartial
- iff false
, may block until a full packet
is read (or EOF), otherwise will return as much data
as is currently available (which may be 0).
null
if the end of
stream has been reached. if no data is available but EOF has not
been reached, the returned buffer will have length 0.
IOException
public abstract int packetsAvailable() throws IOException
IOException
public static byte[] readPacket(InputStream in, byte[] packet) throws IOException
null
will be returned.
in
- the InputStream from which to read datapacket
- the potential output packet (if enough data is available)
null
if the
stream is empty
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |