1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
public class ReadNCharactersGivenReadFour extends Reader4 {
public int read(char[] buf, int n) { char[] buffer = new char[4]; int readByteCount = 0; boolean eof = false; while (readByteCount < n && !eof) { int c = read4(buffer); if (c < 4) { eof = true; } int bytes = Math.min(n - readByteCount, c); System.arraycopy(buffer, 0, buf, readByteCount, bytes); readByteCount += bytes; } return readByteCount; } }
|