Package cardmanager.impl.networking
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 boolean
To mark that the stream is "closed".protected DataInputStream
Data input stream.protected int
Bytes left on input stream for current packet.Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsConstructorDescriptionWrappedInputStream
(InputStream stream) Constructs a wrapper for the given an input stream. -
Method Summary
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, reset
Methods inherited from class java.io.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:
read
in classFilterInputStream
- Throws:
IOException
-
read
Reads a block of bytes and returns the total number of bytes read.- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
Skips the specified number of bytes from the input stream.- Overrides:
skip
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-