public class SonicSessionStream
extends java.io.InputStream
SonicSessionStream
obtains input bytes
from a memStream
and a netStream
.
memStream
is read data from network, netStream
is unread data from network.限定符和类型 | 类和说明 |
---|---|
static interface |
SonicSessionStream.Callback
When
SonicSessionStream close the stream will invoke the Callback |
构造器和说明 |
---|
SonicSessionStream(SonicSessionStream.Callback callback,
java.io.ByteArrayOutputStream outputStream,
java.io.BufferedInputStream netStream)
Constructor
|
限定符和类型 | 方法和说明 |
---|---|
void |
close()
Closes this input stream and releases any system resources
associated with the stream and invoke the callback's onClose method
|
int |
read()
Reads a single byte from this stream and returns it as an integer in the
range from 0 to 255.
|
int |
read(byte[] buffer)
Reads a byte of data from this input stream
Equivalent to
read(buffer, 0, buffer.length) . |
int |
read(byte[] buffer,
int byteOffset,
int byteCount)
Reads up to
byteCount bytes from this stream and stores them in
the byte array buffer starting at byteOffset . |
public SonicSessionStream(SonicSessionStream.Callback callback, java.io.ByteArrayOutputStream outputStream, java.io.BufferedInputStream netStream)
callback
- CallbackoutputStream
- Read data from networknetStream
- Unread data from networkpublic void close() throws java.io.IOException
close
在接口中 java.io.Closeable
close
在接口中 java.lang.AutoCloseable
close
在类中 java.io.InputStream
java.io.IOException
public int read() throws java.io.IOException
Reads a single byte from this stream and returns it as an integer in the range from 0 to 255. Returns -1 if the end of the stream has been reached. Blocks until one byte has been read, the end of the source stream is detected or an exception is thrown.
read
在类中 java.io.InputStream
java.io.IOException
- if the stream is closed or another IOException occurs.public int read(@NonNull byte[] buffer) throws java.io.IOException
read(buffer, 0, buffer.length)
.read
在类中 java.io.InputStream
java.io.IOException
public int read(@NonNull byte[] buffer, int byteOffset, int byteCount) throws java.io.IOException
byteCount
bytes from this stream and stores them in
the byte array buffer
starting at byteOffset
.
Returns the number of bytes actually read or -1 if the end of the stream
has been reached.read
在类中 java.io.InputStream
java.lang.IndexOutOfBoundsException
- if byteOffset < 0 || byteCount < 0 || byteOffset + byteCount > buffer.length
.java.io.IOException
- if the stream is closed or another IOException occurs.