List of utility methods to do Text File Read Line
String | readLines(final File file) read Lines final InputStream stream = new FileInputStream(file); final BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String lines = ""; String line; while ((line = reader.readLine()) != null) lines += line; reader.close(); stream.close(); ... |
String[] | readlines(final File file) readlines final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line = null; final List<String> allLines = new ArrayList<String>(); while ((line = br.readLine()) != null) { allLines.add(line); br.close(); return allLines.toArray(new String[allLines.size()]); ... |
List | readLines(int problemNumber) read Lines String fileName = "src/com/sangupta/maer/dataFiles/problem" + String.valueOf(problemNumber) + ".txt"; return readLines(fileName); |
List | readLines(String body) read Lines final BufferedReader reader = new BufferedReader(new StringReader(body)); final List<String> lines = new ArrayList<String>(); try { for (String line = reader.readLine(); line != null; line = reader.readLine()) { line = line.trim(); if (line.length() > 1) { lines.add(line); } catch (IOException ignored) { return lines; |
Vector | readLines(String file) Read all lines of text in a file. Vector contents = new Vector(); BufferedReader in = new BufferedReader(new FileReader(file)); while (true) { String line = in.readLine(); if (line == null) { break; } else { contents.addElement(line); ... |
List | readLines(String file) read Lines BufferedReader reader = null; List<String> lines; String line; lines = new ArrayList<String>(); try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); while ((line = reader.readLine()) != null) lines.add(line); ... |
void | readLines(String file, ArrayList read Lines BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(new File(file))); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } catch (FileNotFoundException e) { ... |
List | readLines(String filename) read Lines BufferedReader br = new BufferedReader(new FileReader(filename)); ArrayList<String> res = new ArrayList<String>(); while (br.ready()) { res.add(br.readLine()); br.close(); return res; |
List | readLines(String fileName) read Lines File file = new File(fileName); return readLines(file); |
Iterable | readlines(String filename) readlines final FileReader fr = new FileReader(filename); final BufferedReader br = new BufferedReader(fr); return new Iterable<String>() { public Iterator<String> iterator() { return new Iterator<String>() { public boolean hasNext() { return line != null; public String next() { String retval = line; line = getLine(); return retval; public void remove() { throw new UnsupportedOperationException(); String getLine() { String line = null; try { line = br.readLine(); } catch (IOException ioEx) { line = null; return line; String line = getLine(); }; }; |