Here you can find the source of readFile(String file)
public static String readFile(String file)
//package com.java2s; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(String file) { BufferedReader reader;/*w w w . j a v a 2s . com*/ StringBuilder stringBuilder = new StringBuilder(); boolean toggle = false; try { reader = new BufferedReader(new FileReader(file)); String line = null; String ls = System.getProperty("line.separator"); while ((line = reader.readLine()) != null) { if (toggle) { stringBuilder.append(ls); } stringBuilder.append(line); if (!toggle) { toggle = true; } } reader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return stringBuilder.toString(); } }