Here you can find the source of readAsString(String path)
public static String readAsString(String path) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; public class Main { public static String readAsString(String path) throws IOException { try (BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8))) { String line = null;// w w w. ja va 2 s .com StringBuilder sb = new StringBuilder(4096); while ((line = reader.readLine()) != null) { sb.append(line).append('\n'); } return sb.toString(); } } }