Java Path File Read nio readAllLinesOrExit(Path path)

Here you can find the source of readAllLinesOrExit(Path path)

Description

read All Lines Or Exit

License

Apache License

Declaration

public static List<String> readAllLinesOrExit(Path path) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

public class Main {
    public static List<String> readAllLinesOrExit(Path path) {
        try {/*from  www.j  a va2  s.  c o m*/
            return Files.readAllLines(path, Charset.forName("UTF-8"));
        } catch (IOException e) {
            System.err.println("Failed to read [" + path + "]: " + e.getMessage());
            System.exit(0);
        }
        return null;
    }
}

Related

  1. read(String filePath)
  2. read(String filePath)
  3. read(String path)
  4. readAllLines(Path path)
  5. readAllLines(String path)
  6. readAndConsume(String filePath, Consumer consumer)
  7. readAsString(Path path)
  8. readAsString(String path)
  9. reader(String path)