import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; // Reads all the lines of a file and prints them out using BufferedReader/FileReader public class ReadFromFile { public static void main(String[] args) { BufferedReader in = null; try { in = new BufferedReader(new FileReader("ReadFromFile.java")); String st = in.readLine(); while (st != null) { System.out.println(st); st = in.readLine(); } } catch (IOException e) { System.out.println("Input/output error "+e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { System.out.println("Closing file error "+e); } } } } }