Java Utililty Methods Scanner Read Line

List of utility methods to do Scanner Read Line

Description

The list of methods to do Scanner Read Line are organized into topic(s).

Method

StringreadLine(String path)
read Line
return readLine(new File(path));
ListreadLineByLine(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;