Here you can find the source of readFromFile(File file)
public static String readFromFile(File file)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFromFile(File file) { String result = ""; try {//from w w w . j av a 2s . co m BufferedReader in = new BufferedReader(new InputStreamReader( file.toURI().toURL().openStream())); String inputLine = in.readLine(); while (inputLine != null) { result += inputLine + "\n"; inputLine = in.readLine(); } in.close(); } catch (IOException e) { throw new RuntimeException(e); } return result; } }