//Mike Parr 1 dec 04 import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import java.io.*; class EasyFileIn{ private String fileName=""; private BufferedReader inFile; //---- public EasyFileIn(String theInFileName) { fileName=theInFileName; try{ inFile= new BufferedReader(new FileReader(fileName)); } catch ( IOException err){ System.out.println("Error in opening the file: "+ fileName +"\n"+err); System.exit(2); } } //---- public String readLine(){ String line=""; try{ line=inFile.readLine(); } catch(IOException err){ System.out.println("Error in readAllToList, whilst reading file: "+fileName+"\n"); System.out.println(err); System.exit(2); } return line; } //---- public String readAllToString(){ String line; String theContents=""; try{ while ((line = inFile.readLine()) != null) { theContents=theContents+line+"\n"; } } catch(IOException err){ System.out.println("Error in readAllString, whilst reading file: "+fileName+"\n"); System.exit(2); } return theContents; } //---- public ArrayList readAllToList(){ String line; ArrayList list = new ArrayList(); try{ while ((line = inFile.readLine()) != null) { list.add(line); } } catch(IOException err){ System.out.println("Error in readAllToList, whilst reading file: "+fileName); System.exit(2); } return list; } //---- public void close(){ try{ inFile.close(); } catch (IOException err){ System.out.println("Error in close, whilst closing file: "+fileName); System.exit(2); } } }