Class WrappedInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
cardmanager.impl.networking.WrappedInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
This 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanTo mark that the stream is "closed".protected DataInputStreamData input stream.protected intBytes left on input stream for current packet.Fields inherited from class FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionWrappedInputStream(InputStream stream) Constructs a wrapper for the given an input stream. -
Method Summary
Methods inherited from class FilterInputStream
available, mark, markSupported, read, resetMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
fPacketCount
protected int fPacketCountBytes left on input stream for current packet. -
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 fClosedTo mark that the stream is "closed".
-
-
Constructor Details
-
WrappedInputStream
Constructs a wrapper for the given an input stream.
-
-
Method Details
-
read
Reads a single byte.- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
Reads a block of bytes and returns the total number of bytes read.- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
Skips the specified number of bytes from the input stream.- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
close
Closes 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 interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-