Read from Reader and write to Writer until there is no more input from reader. : Reader « File « Java Tutorial






import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class Main {
  /**
   * Read input from reader and write it to writer until there is no more
   * input from reader.
   *
   * @param reader the reader to read from.
   * @param writer the writer to write to.
   * @param buf the char array to use as a bufferx
   */
  public static void flow( Reader reader, Writer writer, char[] buf ) 
      throws IOException {
      int numRead;
      while ( (numRead = reader.read(buf) ) >= 0) {
          writer.write(buf, 0, numRead);
      }
  }
}








11.29.Reader
11.29.1.Read and return the entire contents of the supplied Reader. This method always closes the reader when finished reading.
11.29.2.Read from Reader and write to Writer until there is no more input from reader.
11.29.3.Reads characters available from the Reader and returns these characters as a String object.
11.29.4.Transfers all characters that can be read from one Reader to another Reader
11.29.5.Writes all characters from a Reader to a file using the default character encoding.
11.29.6.convert Reader to InputStream
11.29.7.Compare the contents of two Readers to determine if they are equal or not.
11.29.8.An InputStream backed by a Reader
11.29.9.Reader: Reading Text (Characters)
11.29.10.UTF8 Reader
11.29.11.CRLF Terminated Reader