Here you can find the source of fileToString(File file)
public static String fileToString(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String fileToString(File file) { FileInputStream fis = null; String str = ""; try {//from ww w .j a va2s.co m fis = new FileInputStream(file); int content; while ((content = fis.read()) != -1) { // convert to char and display it str += (char) content; } //System.out.println("After reading file"); //System.out.println(str); return str; } catch (IOException e) { e.printStackTrace(); } finally { try { if (fis != null) fis.close(); } catch (IOException ex) { ex.printStackTrace(); } } return str; } }