Package org.jboss.marshalling
Class ByteInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.jboss.marshalling.SimpleByteInput
-
- org.jboss.marshalling.ByteInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ByteInput
- Direct Known Subclasses:
LimitedByteInput,SimpleDataInput
public class ByteInputStream extends SimpleByteInput
AnInputStreamwhich implementsByteInputand reads bytes from anotherByteInput. Usually theMarshalling.createByteInput(InputStream)method should be used to create instances because it can detect when the target already implementsByteInput.
-
-
Constructor Summary
Constructors Constructor Description ByteInputStream(ByteInput byteInput)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.voidclose()intread()Reads the next byte of data from the input stream.intread(byte[] b)Read some bytes from the input stream into the given array.intread(byte[] b, int off, int len)Read some bytes from the input stream into the given array.longskip(long n)Skips over and discards up tonbytes of data from this input stream.
-
-
-
Field Detail
-
byteInput
protected volatile ByteInput byteInput
-
-
Constructor Detail
-
ByteInputStream
public ByteInputStream(ByteInput byteInput)
Create a new instance.- Parameters:
byteInput- the byte input to read from
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionReads the next byte of data from the input stream. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
-
read
public int read(byte[] b) throws java.io.IOExceptionRead some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionRead some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.- Specified by:
readin interfaceByteInput- Overrides:
readin classjava.io.InputStream- Parameters:
b- the destination arrayoff- the offset into the array into which data should be readlen- the number of bytes to attempt to fill in the destination array- Returns:
- the number of bytes read (possibly zero), or -1 if the end of stream has been reached
- Throws:
java.io.IOException- if an error occurs
-
skip
public long skip(long n) throws java.io.IOExceptionSkips over and discards up tonbytes of data from this input stream. If the end of stream is reached, this method returns0in order to be consistent withInputStream.skip(long).
-
available
public int available() throws java.io.IOExceptionReturns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
-