< prev index next >
src/java.base/share/classes/java/io/StringBufferInputStream.java
Print this page
rev 15365 : imported patch 8163517-Various-cleanup-in-java-io-code
@@ -106,10 +106,11 @@
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> if there is no more data because the end of
* the stream has been reached.
*/
+ @SuppressWarnings("deprecation")
public synchronized int read(byte b[], int off, int len) {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
@@ -124,16 +125,12 @@
len = avail;
}
if (len <= 0) {
return 0;
}
- String s = buffer;
- int cnt = len;
- while (--cnt >= 0) {
- b[off++] = (byte)s.charAt(pos++);
- }
-
+ buffer.getBytes(pos, pos + len, b, off);
+ pos += len;
return len;
}
/**
* Skips <code>n</code> bytes of input from this input stream. Fewer
< prev index next >