SocketInputStreampublic class SocketInputStream extends InputStream The SocketInputStream supports the streamed reading of bytes from a socket.
Multiple streams may be opened on a socket, so care should be taken to manage
opened streams and coordinate read operations between threads. |
Fields Summary |
---|
private final PlainSocketImpl | socket |
Constructors Summary |
---|
public SocketInputStream(SocketImpl socket)Constructs a SocketInputStream for the socket . Read
operations are forwarded to the socket .
super();
this.socket = (PlainSocketImpl) socket;
|
Methods Summary |
---|
public int | available()
return socket.available();
| public void | close()
socket.close();
| public int | read()
byte[] buffer = new byte[1];
int result = socket.read(buffer, 0, 1);
return (-1 == result) ? result : buffer[0] & 0xFF;
| public int | read(byte[] buffer)
return read(buffer, 0, buffer.length);
| public int | read(byte[] buffer, int offset, int count)
if (null == buffer) {
throw new IOException(Msg.getString("K0047"));//$NON-NLS-1$
}
if (0 == count) {
return 0;
}
if (0 > offset || offset >= buffer.length) {
throw new ArrayIndexOutOfBoundsException(Msg.getString("K002e"));//$NON-NLS-1$
}
if (0 > count || offset + count > buffer.length) {
throw new ArrayIndexOutOfBoundsException(Msg.getString("K002f"));//$NON-NLS-1$
}
return socket.read(buffer, offset, count);
| public long | skip(long n)
return (0 == n) ? 0 : super.skip(n);
|
|