Reading Text from a File - Java File Path IO

Java examples for File Path IO:Text File

Description

Reading Text from a File

Demo Code

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

public class Main {

  public void main(String[] argv) {
    try {//ww w  . ja  v  a2 s .c om
      BufferedReader in = new BufferedReader(new FileReader("infilename"));
      String str;
      while ((str = in.readLine()) != null) {
        System.out.println(str);
      }
      in.close();
    } catch (IOException e) {
    }
  }
}

Related Tutorials