List of utility methods to do Text File Read Line
String[] | readLines(String text) read Lines return text.split("\\r?\\n"); |
void | readLines2Lowcase(String inputFile, ArrayList read Lines Lowcase BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(new File(inputFile))); String line = null; while ((line = reader.readLine()) != null) { lines.add(line.toLowerCase()); } catch (FileNotFoundException e) { ... |
ArrayList | readLinesAsList(String filename) read Lines As List FileReader fileReader = new FileReader(filename); BufferedReader bufferedReader = new BufferedReader(fileReader); ArrayList<String> lines = new ArrayList<String>(); String line = null; while ((line = bufferedReader.readLine()) != null) { lines.add(line); bufferedReader.close(); ... |
String | readLinesFileSimple(final File inFile, final int prefixMode, final String prefix) Implementation Routine readLinesFileSimple. try { return readLinesFile(inFile, prefixMode, prefix); } catch (IOException e) { e.printStackTrace(); return ""; |
int | readLinesFromCommand(String command[], List read Lines From Command if (command == null || buffer == null) { return -2; Process cmdProc = null; try { cmdProc = Runtime.getRuntime().exec(command); } catch (IOException e) { System.out.printf("`%s` failed\n", Arrays.toString(command)); ... |
List | readLinesNoComments(String fileName) read Lines No Comments return readLinesNoComments(fileName, null);
|
String | readLinesRaw(final File inFile) Count the number of lines in the buffer. final StringBuffer resultBuffer = new StringBuffer(128); final FileInputStream stream = new FileInputStream(inFile); final BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); try { String data = ""; int lineNumber = 1; do { data = reader.readLine(); ... |
String[] | readLinesTrimmedNoComment(final String fileName, final String commentString) read Lines Trimmed No Comment File wtsFile = new File(fileName); if (!wtsFile.isFile()) throw new FileNotFoundException("Cannot find file for reading: " + fileName); FileInputStream fin = null; BufferedReader in = null; try { fin = new FileInputStream(wtsFile); in = new BufferedReader(new InputStreamReader(fin)); ... |
ArrayList | readLinesWithPattern(File file, Pattern pattern) read Lines With Pattern ArrayList<String> strs = new ArrayList<>(); try { Scanner sc = new Scanner(file); while (sc.hasNextLine()) { Scanner lineSc = new Scanner(sc.nextLine()); String str = lineSc.findInLine(pattern); if (str != null) { strs.add(str.trim()); ... |