java.net
Class SocketInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FileInputStream
|
+--java.net.SocketInputStream
- class SocketInputStream
- extends FileInputStream
Field Summary
private boolean
closing
Closes the stream.
Constructor Summary
Method Summary
int
available()
Returns the number of bytes that can be read without blocking.
void
close()
Enabled: Closes this file input stream and releases any system resources
associated with the stream.
protected void
finalize()
Overrides finalize, the fd is closed by the Socket.
java.nio.channels.FileChannel
getChannel()
Returns the unique
FileChannel
object associated with this file input stream.
private static void
init()
Perform class load-time initializations.
int
read()
Reads a single byte from the socket.
int
read(byte[] b)
Reads into a byte array data from the socket.
int
read(byte[] b,
int off,
int length)
Reads into a byte array
b at offset
off,
length bytes of data.
(package private) void
setEOF(boolean eof)
long
skip(long numbytes)
Skips n bytes of input.
private int
socketRead0(FileDescriptor fd,
byte[] b,
int off,
int len,
int timeout)
Reads into an array of bytes at the specified offset using
the received socket primitive.
Methods inherited from class java.lang.Object
Field Detail
eof
private boolean eof
impl
private PlainSocketImpl impl
temp
private byte[] temp
socket
private Socket socket
closing
private boolean closing
- Closes the stream.
Constructor Detail
SocketInputStream
SocketInputStream(PlainSocketImpl impl)
throws IOException
- Creates a new SocketInputStream. Can only be called
by a Socket. This method needs to hang on to the owner Socket so
that the fd will not be closed.
- Parameters:
impl - the implemented socket input stream
Method Detail
getChannel
public final java.nio.channels.FileChannel getChannel()
- Returns the unique
FileChannel
object associated with this file input stream.
The getChannel method of SocketInputStream
returns null since it is a socket based stream.
- Overrides:
getChannel in class FileInputStream
- Returns:
- the file channel associated with this file input stream
- Since:
- 1.4
socketRead0
private int socketRead0(FileDescriptor fd,
byte[] b,
int off,
int len,
int timeout)
throws IOException
- Reads into an array of bytes at the specified offset using
the received socket primitive.
- Parameters:
fd - the FileDescriptorb - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes readtimeout - the read timeout in ms
- Returns:
- the actual number of bytes read, -1 is
returned when the end of the stream is reached.
IOException
read
public int read(byte[] b)
throws IOException
- Reads into a byte array data from the socket.
- Overrides:
read in class FileInputStream
- Parameters:
b - the buffer into which the data is read
- Returns:
- the actual number of bytes read, -1 is
returned when the end of the stream is reached.
IOException
read
public int read(byte[] b,
int off,
int length)
throws IOException
- Reads into a byte array b at offset off,
length bytes of data.
- Overrides:
read in class FileInputStream
- Parameters:
b - the buffer into which the data is readoff - the start offset of the datalength - the maximum number of bytes read.
- Returns:
- the actual number of bytes read, -1 is
returned when the end of the stream is reached.
IOException
read
public int read()
throws IOException
- Reads a single byte from the socket.
- Overrides:
read in class FileInputStream
- Returns:
- the next byte of data, or
-1 if the end of the
file is reached.
IOException
skip
public long skip(long numbytes)
throws IOException
- Skips n bytes of input.
- Overrides:
skip in class FileInputStream
- Parameters:
numbytes - the number of bytes to be skipped.
- Returns:
- the actual number of bytes skipped.
IOException
available
public int available()
throws IOException
- Returns the number of bytes that can be read without blocking.
- Overrides:
available in class FileInputStream
- Returns:
- the number of immediately available bytes
IOException
close
public void close()
throws IOException
- Description copied from class:
FileInputStream
- Enabled: Closes this file input stream and releases any system resources
associated with the stream.
If this stream has an associated channel then the channel is closed
as well.
- Overrides:
close in class FileInputStream
IOException
setEOF
void setEOF(boolean eof)
-
finalize
protected void finalize()
- Overrides finalize, the fd is closed by the Socket.
- Overrides:
finalize in class FileInputStream
- See Also:
java.io.FileInputStream#close()
init
private static void init()
- Perform class load-time initializations.
-