Java Path File Read nio loadFile(final Path p)

Here you can find the source of loadFile(final Path p)

Description

load File

License

Open Source License

Declaration

private static String loadFile(final Path p) 

Method Source Code

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

import java.io.FileNotFoundException;

import java.nio.file.Path;

import java.util.Scanner;

public class Main {
    private static String loadFile(final Path p) {
        Scanner in = null;/*from ww  w  . j a v a  2s.co m*/
        try {
            in = new Scanner(p.toFile());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        StringBuffer buffer = new StringBuffer();
        while (in.hasNextLine()) {
            buffer.append(in.nextLine() + "\n");
        }
        return buffer.toString();
    }
}

Related

  1. getReaderForFile(final Path file)
  2. getResourceAsStream(String resourcePath, ClassLoader classLoader, Class clazz, String resourceDesc, Consumer logger)
  3. getTestClassPathURLClassLoader(ClassLoader parent)
  4. load(Path p, PrintStream errorStream, String propertyInfo)
  5. loadFile(final Path filePath)
  6. loadFile(Path file)
  7. loadFile(String path)
  8. loadFromFile(Path path)
  9. loadJSON(Path path)