Here you can find the source of loadFile(final Path p)
private static String loadFile(final Path p)
//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(); } }