equal
deleted
inserted
replaced
25 |
25 |
26 package java.io; |
26 package java.io; |
27 |
27 |
28 import java.nio.charset.Charset; |
28 import java.nio.charset.Charset; |
29 import java.util.Arrays; |
29 import java.util.Arrays; |
|
30 import java.util.Objects; |
30 |
31 |
31 /** |
32 /** |
32 * This class implements an output stream in which the data is |
33 * This class implements an output stream in which the data is |
33 * written into a byte array. The buffer automatically grows as data |
34 * written into a byte array. The buffer automatically grows as data |
34 * is written to it. |
35 * is written to it. |
145 * @param b the data. |
146 * @param b the data. |
146 * @param off the start offset in the data. |
147 * @param off the start offset in the data. |
147 * @param len the number of bytes to write. |
148 * @param len the number of bytes to write. |
148 */ |
149 */ |
149 public synchronized void write(byte b[], int off, int len) { |
150 public synchronized void write(byte b[], int off, int len) { |
150 if ((off < 0) || (off > b.length) || (len < 0) || |
151 Objects.checkFromIndexSize(off, len, b.length); |
151 ((off + len) - b.length > 0)) { |
|
152 throw new IndexOutOfBoundsException(); |
|
153 } |
|
154 ensureCapacity(count + len); |
152 ensureCapacity(count + len); |
155 System.arraycopy(b, off, buf, count, len); |
153 System.arraycopy(b, off, buf, count, len); |
156 count += len; |
154 count += len; |
157 } |
155 } |
158 |
156 |