< prev index next >
src/java.base/share/classes/java/io/ByteArrayInputStream.java
Print this page
*** 51,61 ****
* through {@code buf[count-1]} are the
* only bytes that can ever be read from the
* stream; element {@code buf[pos]} is
* the next byte to be read.
*/
! protected byte buf[];
/**
* The index of the next character to read from the input stream buffer.
* This value should always be nonnegative
* and not larger than the value of {@code count}.
--- 51,61 ----
* through {@code buf[count-1]} are the
* only bytes that can ever be read from the
* stream; element {@code buf[pos]} is
* the next byte to be read.
*/
! protected byte[] buf;
/**
* The index of the next character to read from the input stream buffer.
* This value should always be nonnegative
* and not larger than the value of {@code count}.
*** 100,110 ****
* of {@code count} is the length of
* {@code buf}.
*
* @param buf the input buffer.
*/
! public ByteArrayInputStream(byte buf[]) {
this.buf = buf;
this.pos = 0;
this.count = buf.length;
}
--- 100,110 ----
* of {@code count} is the length of
* {@code buf}.
*
* @param buf the input buffer.
*/
! public ByteArrayInputStream(byte[] buf) {
this.buf = buf;
this.pos = 0;
this.count = buf.length;
}
*** 120,130 ****
*
* @param buf the input buffer.
* @param offset the offset in the buffer of the first byte to read.
* @param length the maximum number of bytes to read from the buffer.
*/
! public ByteArrayInputStream(byte buf[], int offset, int length) {
this.buf = buf;
this.pos = offset;
this.count = Math.min(offset + length, buf.length);
this.mark = offset;
}
--- 120,130 ----
*
* @param buf the input buffer.
* @param offset the offset in the buffer of the first byte to read.
* @param length the maximum number of bytes to read from the buffer.
*/
! public ByteArrayInputStream(byte[] buf, int offset, int length) {
this.buf = buf;
this.pos = offset;
this.count = Math.min(offset + length, buf.length);
this.mark = offset;
}
*** 167,177 ****
* @throws NullPointerException If {@code b} is {@code null}.
* @throws IndexOutOfBoundsException If {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}
*/
! public synchronized int read(byte b[], int off, int len) {
Objects.checkFromIndexSize(off, len, b.length);
if (pos >= count) {
return -1;
}
--- 167,177 ----
* @throws NullPointerException If {@code b} is {@code null}.
* @throws IndexOutOfBoundsException If {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}
*/
! public synchronized int read(byte[] b, int off, int len) {
Objects.checkFromIndexSize(off, len, b.length);
if (pos >= count) {
return -1;
}
< prev index next >