Buffered Stream Copier : BufferedInputStream « File « Java Tutorial






import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class MainClass {

  public static void main(String[] args) {

    try {
      copy(System.in, System.out);
    } catch (IOException ex) {
      System.err.println(ex);
    }
  }

  public static void copy(InputStream in, OutputStream out) throws IOException {

    BufferedInputStream bin = new BufferedInputStream(in);
    BufferedOutputStream bout = new BufferedOutputStream(out);

    while (true) {
      int datum = bin.read();
      if (datum == -1)
        break;
      bout.write(datum);
    }
    bout.flush();
  }
}








11.9.BufferedInputStream
11.9.1.BufferedInputStream
11.9.2.Buffered Stream Copier
11.9.3.Read from file with BufferedInputStream
11.9.4.Read File in String Using Java BufferedInputStream Example
11.9.5.Read File Using Java BufferedInputStream Example
11.9.6.Use buffered streams to copy a file
11.9.7.Import a file of exported preference data.
11.9.8.Save keyboard input with BufferedInputStream