1 11 package org.eclipse.help.internal.search; 12 13 import java.io.*; 14 15 18 public class ASCIIReader extends Reader { 19 private InputStream stream; 20 int bufSize; 21 byte[] buf; 22 28 public ASCIIReader(InputStream stream, int bufSize) { 29 this.stream = stream; 30 this.bufSize = bufSize; 31 buf = new byte[bufSize]; 32 } 33 34 37 public int read(char[] cbuf, int off, int len) throws IOException { 38 int n = stream.read(buf, 0, Math.min(bufSize, len)); 39 for (int i = 0; i < n; i++) { 40 cbuf[off + i] = (char) buf[i]; 41 } 42 return n; 43 } 44 45 48 public void close() throws IOException { 49 stream.close(); 50 } 51 52 } 53 | Popular Tags |