Here you can find the source of fileToString(String fileName)
public static String fileToString(String fileName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String fileToString(String fileName) throws IOException { String result = ""; try {/*from w ww. ja va2 s .c om*/ FileInputStream file = new FileInputStream(fileName); byte[] b = new byte[file.available()]; file.read(b); file.close(); result = new String(b); } catch (FileNotFoundException e) { System.out.println("oops"); } return result; } }