Here you can find the source of readFile(String fileName)
static private String readFile(String fileName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { static private String readFile(String fileName) throws IOException { String everything = ""; try (BufferedReader br = new BufferedReader(new FileReader(fileName))) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line);//w w w .j a v a 2s . c om sb.append(System.lineSeparator()); line = br.readLine(); } everything = sb.toString().substring(0, sb.length() - 2); } catch (IOException e) { throw e; } return everything; } }