private String physReadTextFile(File file) { // physically read text file try { BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(file))); StringBuffer tmp = new StringBuffer(); while (input.ready()) { tmp.append(input.readLine()); tmp.append("\n"); } return tmp.toString(); } catch (FileNotFoundException e) { // not sure how this can happen showErrorDialog("Unable to load \"" + file.getName() + "\" (file not found)"); } catch (IOException e) { // This happens if e.g. file already exists and // we do not have write permissions showErrorDialog("Unable to load \"" + file.getName() + "\" (I/O error)"); } return new String(""); }