/[classpath]/gjdoc/src/gnu/classpath/tools/IOToolkit.java
ViewVC logotype

Diff of /gjdoc/src/gnu/classpath/tools/IOToolkit.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by julian, Fri Dec 3 18:54:36 2004 UTC revision 1.2 by julian, Fri Dec 10 14:47:01 2004 UTC
# Line 27  import java.io.IOException; Line 27  import java.io.IOException;
27  import java.io.InputStream;  import java.io.InputStream;
28  import java.io.OutputStream;  import java.io.OutputStream;
29  import java.io.Reader;  import java.io.Reader;
30    import java.io.StringWriter;
31  import java.io.Writer;  import java.io.Writer;
32    
33  import java.util.Set;  import java.util.Set;
# Line 144  public class IOToolkit Line 145  public class IOToolkit
145        in.close();        in.close();
146        out.close();        out.close();
147     }     }
148    
149       /**
150        *  Read the (remaining) contents of the given reader into a char
151        *  array. This method doesn't close the reader when it is done.
152        *
153        *  @param reader the Reader to read characters from
154        *  @return an array with the contents of the Reader
155        */
156       public static char[] readFully(Reader reader)
157          throws IOException
158       {
159          StringWriter writer = new StringWriter();
160          final int readBufferSize = 256;
161          char[] chunk = new char[readBufferSize];
162          int nread;
163          while ((nread=reader.read(chunk))>=0) {
164             writer.write(chunk,0,nread);
165          }
166          StringBuffer buffer = writer.getBuffer();
167          char[] result = new char[buffer.length()];
168          buffer.getChars(0, buffer.length(), result, 0);
169          return result;
170       }
171  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26