how to read lines from a file and print these to the standard output stream : Buffered Reader Writer « File Input Output « Java





how to read lines from a file and print these to the standard output stream

  
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

class FileReaderDemo {
  public static void main(String args[]) throws IOException {
    FileReader fr = new FileReader("FileReaderDemo.java");
    BufferedReader br = new BufferedReader(fr);
    String s;

    while ((s = br.readLine()) != null) {
      System.out.println(s);
    }

    fr.close();
  }
}

   
  










Related examples in the same category

1.Use a BufferedReader to read characters from the console.
2.Read a string from console using a BufferedReader.
3.Creates a tiny text editor with BufferedReader
4.Writing to a Text File
5.Fast BufferedWriter