Here you can find the source of fileToString(String fileName)
public static String fileToString(String fileName) throws FileNotFoundException
//package com.java2s; import java.io.*; import java.util.Scanner; public class Main { public static String fileToString(String fileName) throws FileNotFoundException { File file = new File(fileName); return fileToString(file); }//from w w w . ja va2s .c o m public static String fileToString(File file) throws FileNotFoundException { String s = null; try { s = new Scanner(file).useDelimiter("\\Z").next(); } catch (FileNotFoundException e) { e.printStackTrace(); } return s; } }