Here you can find the source of readFromFile(Path path)
public static String readFromFile(Path path)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; import java.nio.file.*; public class Main { public static String readFromFile(Path path) { try (FileInputStream stream = new FileInputStream(path.toFile())) { FileChannel fc = stream.getChannel(); MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); return Charset.defaultCharset().decode(bb).toString(); } catch (IOException e) { e.printStackTrace();/*from w w w. ja va 2 s .c o m*/ } return ""; } }