Here you can find the source of ReadFile(File f, boolean keep_newline)
public static String ReadFile(File f, boolean keep_newline)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String ReadFile(File f) { return ReadFile(f, false); }/*from w w w . j ava 2 s . co m*/ public static String ReadFile(File f, boolean keep_newline) { try { StringBuilder sb = new StringBuilder(); java.io.BufferedReader br = new BufferedReader( new FileReader(f)); String line = null; while ((line = br.readLine()) != null) { //System.out.println(line); sb.append((sb.length() > 0 ? (keep_newline ? "\n" : " ") : "") + line); } br.close(); return sb.toString(); } catch (Exception e) { System.out.println("ERROR: " + e); return null; } } }