Here you can find the source of readLineByLine(String filePath)
private static String readLineByLine(String filePath)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; public class Main { private static String readLineByLine(String filePath) { StringBuilder contentBuilder = new StringBuilder(); try (Stream<String> stream = Files.lines(Paths.get(filePath), StandardCharsets.UTF_8)) { stream.forEach(s -> contentBuilder.append(s).append("\n")); } catch (IOException e) { e.printStackTrace();/* w w w. j a v a 2 s . c o m*/ } return contentBuilder.toString(); } }