1 11 package org.eclipse.jdt.internal.corext.javadoc; 12 13 14 import java.io.IOException ; 15 import java.io.Reader ; 16 17 public abstract class SingleCharReader extends Reader { 18 19 22 public abstract int read() throws IOException ; 23 24 27 public int read(char cbuf[], int off, int len) throws IOException { 28 int end= off + len; 29 for (int i= off; i < end; i++) { 30 int ch= read(); 31 if (ch == -1) { 32 if (i == off) { 33 return -1; 34 } else { 35 return i - off; 36 } 37 } 38 cbuf[i]= (char)ch; 39 } 40 return len; 41 } 42 43 46 public boolean ready() throws IOException { 47 return true; 48 } 49 50 53 public String getString() throws IOException { 54 StringBuffer buf= new StringBuffer (); 55 int ch; 56 while ((ch= read()) != -1) { 57 buf.append((char)ch); 58 } 59 return buf.toString(); 60 } 61 } 62 | Popular Tags |