import java.io.BufferedReader; import java.io.FileReader; public class FileExample2 { public static void main(String[] args) throws MyError { BufferedReader file = null; String sCurrentLine; try{ file = new BufferedReader(new FileReader("example.txt")); while ( (sCurrentLine = file.readLine()) != null) { System.out.println(sCurrentLine); } } catch (java.io.IOException e){ System.out.println("something bad happened with the file!"); } finally{ try{ if (file != null) file.close(); } catch(java.io.IOException e){ System.out.println("arghhh! close did not work"); } } } // main } // FileExample