public class SocketInputStream extends InputStream implements ReadableByteChannel
Socket.getInputStream() and write() on
Socket.getOutputStream() for the associated socket will throw
IllegalBlockingModeException.
Please use SocketOutputStream for writing.| 构造器和说明 |
|---|
SocketInputStream(ReadableByteChannel channel,
long timeout)
Create a new input stream with the given timeout.
|
SocketInputStream(Socket socket)
Same as SocketInputStream(socket.getChannel(), socket.getSoTimeout())
:
Create a new input stream with the given timeout. |
SocketInputStream(Socket socket,
long timeout)
Same as SocketInputStream(socket.getChannel(), timeout):
Create a new input stream with the given timeout. |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
ReadableByteChannel |
getChannel()
Returns underlying channel used by inputstream.
|
boolean |
isOpen() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
int |
read(ByteBuffer dst) |
void |
waitForReadable()
waits for the underlying channel to be ready for reading.
|
available, mark, markSupported, read, reset, skippublic SocketInputStream(ReadableByteChannel channel, long timeout) throws IOException
channel - Channel for reading, should also be a SelectableChannel.
The channel will be configured to be non-blocking.timeout - timeout in milliseconds. must not be negative.IOExceptionpublic SocketInputStream(Socket socket, long timeout) throws IOException
socket - should have a channel associated with it.timeout - timeout timeout in milliseconds. must not be negative.IOExceptionSocketInputStream(ReadableByteChannel, long)public SocketInputStream(Socket socket) throws IOException
socket - should have a channel associated with it.IOExceptionSocketInputStream(ReadableByteChannel, long)public int read()
throws IOException
read 在类中 InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read 在类中 InputStreamIOExceptionpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在接口中 Channelclose 在类中 InputStreamIOExceptionpublic ReadableByteChannel getChannel()
FileChannel.transferFrom(ReadableByteChannel, long, long).public int read(ByteBuffer dst) throws IOException
read 在接口中 ReadableByteChannelIOExceptionpublic void waitForReadable()
throws IOException
SocketTimeoutException - if select on the channel times out.IOException - if any other I/O error occurs.Copyright © 2009 The Apache Software Foundation