1 11 package org.eclipse.jface.internal.text.html; 12 13 import java.io.IOException ; 14 import java.io.Reader ; 15 16 17 21 public abstract class SingleCharReader extends Reader { 22 23 26 public abstract int read() throws IOException ; 27 28 31 public int read(char cbuf[], int off, int len) throws IOException { 32 int end= off + len; 33 for (int i= off; i < end; i++) { 34 int ch= read(); 35 if (ch == -1) { 36 if (i == off) 37 return -1; 38 return i - off; 39 } 40 cbuf[i]= (char)ch; 41 } 42 return len; 43 } 44 45 48 public boolean ready() throws IOException { 49 return true; 50 } 51 52 57 public String getString() throws IOException { 58 StringBuffer buf= new StringBuffer (); 59 int ch; 60 while ((ch= read()) != -1) { 61 buf.append((char)ch); 62 } 63 return buf.toString(); 64 } 65 } 66 | Popular Tags |