Here you can find the source of readFile(File f)
public static String readFile(File f)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File f) { try (BufferedReader br = new BufferedReader(new FileReader(f))) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line);/*from ww w . j a va 2s. c om*/ sb.append(System.lineSeparator()); line = br.readLine(); } return sb.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }