Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String stringFromFile(final File file) throws IOException { final BufferedReader br = new BufferedReader(new FileReader(file)); try { final StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } return sb.toString(); } finally { br.close(); } } }