List of utility methods to do FileReader Create
List | readTextFileAsList(File file) Read text file as String List<String> lines = new ArrayList<String>(); BufferedReader reader = new BufferedReader(new FileReader(file)); String temp = null; try { while ((temp = reader.readLine()) != null) { lines.add(temp); } finally { ... |
String | readTextFileContents(File fFile) Reads the text file contents and returns it as a string. if (fFile == null) { throw new NullPointerException("File is null."); Reader rReader = null; try { rReader = new FileReader(fFile); return readReaderContents(rReader); } finally { ... |
String | readTextFileFully(File file) Will skip lines starting with // BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); StringBuilder buffer = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { if (!line.startsWith("//")) { buffer.append(line).append('\n'); ... |
ArrayList | readTextFileLines(String fullPathFilename) read Text File Lines ArrayList<String> datas = new ArrayList(); StringBuilder sb = new StringBuilder(1024); BufferedReader reader = new BufferedReader(new FileReader(fullPathFilename)); char[] chars = new char[1024]; String s; while ((s = reader.readLine()) != null) { datas.add(s); reader.close(); return datas; |