The Java Program: Convert.java

  1 import java.io.Reader;
  2 import java.io.IOException;
  3 
  4 
  5 public class Convert {
  6    public static String toString (Reader r) throws IOException {
  7       final StringBuffer buf = new StringBuffer(1000);
  8       int ch;
  9       while ((ch=r.read())>-1) {
 10          buf.append((char)ch);
 11       }
 12       return (new String (buf));
 13    }
 14 }
 15