Package cardmanager.impl.networking
Class WrappedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- cardmanager.impl.networking.WrappedInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class WrappedInputStream extends java.io.FilterInputStreamThis input stream works in conjunction with the WrappedOutputStream to introduce a protocol for reading arbitrary length data in a uniform way.Note: See the javadoc for WrappedOutputStream for more information.
- See Also:
WrappedOutputStream
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanfClosedTo mark that the stream is "closed".protected java.io.DataInputStreamfDataInputStreamData input stream.protected intfPacketCountBytes left on input stream for current packet.
-
Constructor Summary
Constructors Constructor Description WrappedInputStream(java.io.InputStream stream)Constructs a wrapper for the given an input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the input stream.intread()Reads a single byte.intread(byte[] b, int offset, int length)Reads a block of bytes and returns the total number of bytes read.longskip(long n)Skips the specified number of bytes from the input stream.
-
-
-
Field Detail
-
fPacketCount
protected int fPacketCount
Bytes left on input stream for current packet.
-
fDataInputStream
protected java.io.DataInputStream fDataInputStream
Data input stream. This stream is used to input the block sizes from the data stream that are written by the WrappedOutputStream.Note: The data input stream is only used for reading the byte count for performance reasons. We avoid the method indirection for reading the byte data.
-
fClosed
protected boolean fClosed
To mark that the stream is "closed".
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionReads a single byte.- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int offset, int length) throws java.io.IOExceptionReads a block of bytes and returns the total number of bytes read.- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOExceptionSkips the specified number of bytes from the input stream.- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses the input stream. This method will search for the end of the wrapped input, positioning the stream at after the end packet.Note: This method does not close the underlying input stream.
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
-