asclass ShortInputStream { public int read(short[] destination) throws IOException { ret read(destination, 0, l(destination)); } public int read(short[] destination, int off, int len) throws IOException { int n = 0; while (n < len) { int i = read(); if (i == Int.MIN_VALUE) break; destination[off+n] = (short) i; n++; } ret n; } public abstract int read() throws IOException; public void readFully(short[] destination) throws IOException { readFully(destination, 0, destination.length); } public void readFully(short[] destination, int offset, int length) throws IOException { int read = 0; while (read < length) { int r = read(destination, offset+read, length-read); if (r == -1) throw new EOFException("Asked to read " + length + " bytes from " + offset + " but hit EoF at " + read); else read += r; } } }