import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; /** Simple class that reads from a file and returns each line at a time */ public class ReadFile { private BufferedReader in; private String str; public ReadFile(String dirname) { try { in = new BufferedReader(new FileReader(dirname)) ; } catch (FileNotFoundException fnfe){ System.out.println("file " + dirname + " not found"); } } public String readLine() { try { str = in.readLine(); return str; } catch (IOException ioe){System.out.println("IOException while tying to read from a file "); } return null; } public void close() { try { in.close(); } catch (IOException ioe){System.out.println("IOException while tying to close the file "); } } }