Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String getStringByFile(File f) throws IOException { StringBuilder builder = new StringBuilder(); BufferedReader br = new BufferedReader(new FileReader(f)); String line; while ((line = br.readLine()) != null) { builder.append(line); } br.close(); return builder.toString(); } }