List of utility methods to do Scanner Read Line
String | readLine(String path) read Line return readLine(new File(path)); |
List | readLineByLine(String fileName) read Line By Line String fileEncoding = getFileEncoding(); List<String> lines = new ArrayList<String>(); Scanner scanner = null; try { scanner = new Scanner(new FileInputStream(fileName), fileEncoding); while (scanner.hasNextLine()) { lines.add(scanner.nextLine()); } catch (FileNotFoundException e) { throw new IllegalStateException(e); } finally { if (scanner != null) scanner.close(); return lines; |