Here you can find the source of fileToString(File f)
public static String fileToString(File f) throws FileNotFoundException
//package com.java2s; //License from project: Creative Commons License import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static String fileToString(File f) throws FileNotFoundException { Scanner m = new Scanner(f); String s = ""; while (m.hasNextLine()) { s = s + m.nextLine().trim() + "\n"; }// w ww. ja va 2 s. c om m.close(); return s.trim(); } }