1 11 package org.eclipse.ant.internal.ui.editor.derived; 12 13 14 import java.io.IOException ; 15 import java.io.Reader ; 16 17 20 public abstract class SingleCharReader extends Reader { 21 22 25 public abstract int read() throws IOException ; 26 27 30 public int read(char cbuf[], int off, int len) throws IOException { 31 int end= off + len; 32 for (int i= off; i < end; i++) { 33 int ch= read(); 34 if (ch == -1) { 35 if (i == off) { 36 return -1; 37 } 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 55 public String getString() throws IOException { 56 StringBuffer buf= new StringBuffer (); 57 int ch; 58 while ((ch= read()) != -1) { 59 buf.append((char)ch); 60 } 61 return buf.toString(); 62 } 63 } 64 | Popular Tags |