Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Main { public static String read(File file) { if (!file.exists()) { return ""; } try { FileReader reader = new FileReader(file); BufferedReader br = new BufferedReader(reader); StringBuffer buffer = new StringBuffer(); String s; while ((s = br.readLine()) != null) { buffer.append(s); } return buffer.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return ""; } }