< prev index next >
src/java.base/share/classes/java/net/SocketInputStream.java
Print this page
*** 45,55 ****
init();
}
private boolean eof;
private AbstractPlainSocketImpl impl = null;
! private byte temp[];
private Socket socket = null;
/**
* Creates a new SocketInputStream. Can only be called
* by a Socket. This method needs to hang on to the owner Socket so
--- 45,55 ----
init();
}
private boolean eof;
private AbstractPlainSocketImpl impl = null;
! private byte[] temp;
private Socket socket = null;
/**
* Creates a new SocketInputStream. Can only be called
* by a Socket. This method needs to hang on to the owner Socket so
*** 89,99 ****
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
private native int socketRead0(FileDescriptor fd,
! byte b[], int off, int len,
int timeout)
throws IOException;
// wrap native call to allow instrumentation
/**
--- 89,99 ----
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
private native int socketRead0(FileDescriptor fd,
! byte[] b, int off, int len,
int timeout)
throws IOException;
// wrap native call to allow instrumentation
/**
*** 107,117 ****
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
private int socketRead(FileDescriptor fd,
! byte b[], int off, int len,
int timeout)
throws IOException {
return socketRead0(fd, b, off, len, timeout);
}
--- 107,117 ----
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
private int socketRead(FileDescriptor fd,
! byte[] b, int off, int len,
int timeout)
throws IOException {
return socketRead0(fd, b, off, len, timeout);
}
*** 120,130 ****
* @param b the buffer into which the data is read
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
! public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
}
/**
* Reads into a byte array <i>b</i> at offset <i>off</i>,
--- 120,130 ----
* @param b the buffer into which the data is read
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
! public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
/**
* Reads into a byte array <i>b</i> at offset <i>off</i>,
*** 134,148 ****
* @param length the maximum number of bytes read
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
! public int read(byte b[], int off, int length) throws IOException {
return read(b, off, length, impl.getTimeout());
}
! int read(byte b[], int off, int length, int timeout) throws IOException {
int n;
// EOF already encountered
if (eof) {
return -1;
--- 134,148 ----
* @param length the maximum number of bytes read
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @exception IOException If an I/O error has occurred.
*/
! public int read(byte[] b, int off, int length) throws IOException {
return read(b, off, length, impl.getTimeout());
}
! int read(byte[] b, int off, int length, int timeout) throws IOException {
int n;
// EOF already encountered
if (eof) {
return -1;
*** 214,224 ****
if (numbytes <= 0) {
return 0;
}
long n = numbytes;
int buflen = (int) Math.min(1024, n);
! byte data[] = new byte[buflen];
while (n > 0) {
int r = read(data, 0, (int) Math.min((long) buflen, n));
if (r < 0) {
break;
}
--- 214,224 ----
if (numbytes <= 0) {
return 0;
}
long n = numbytes;
int buflen = (int) Math.min(1024, n);
! byte[] data = new byte[buflen];
while (n > 0) {
int r = read(data, 0, (int) Math.min((long) buflen, n));
if (r < 0) {
break;
}
< prev index next >