Java Path File Read nio read(String path)

Here you can find the source of read(String path)

Description

read

License

Open Source License

Declaration

public static String read(String path) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class Main {
    public static String read(String path) throws IOException {
        String content = "";
        List<String> lines = Files.readAllLines(Paths.get(path), StandardCharsets.UTF_8);
        for (String line : lines) {
            content += line + "\n";
        }/*  w w  w .java 2 s.c  o  m*/
        return content;
    }
}

Related

  1. openForReadingAndWriting(String filePath)
  2. openResourceReader(Class resourceOrigin, String resourcePath)
  3. read(String aPathString)
  4. read(String filePath)
  5. read(String filePath)
  6. readAllLines(Path path)
  7. readAllLines(String path)
  8. readAllLinesOrExit(Path path)
  9. readAndConsume(String filePath, Consumer consumer)