Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readString(File file) { int len = 0; StringBuffer str = new StringBuffer(""); try { FileInputStream is = new FileInputStream(file); InputStreamReader isr = new InputStreamReader(is, "UTF-8"); BufferedReader in = new BufferedReader(isr); String line = null; while ((line = in.readLine()) != null) { if (len != 0) { str.append("\r\n" + line); } else { str.append(line); } len++; } in.close(); is.close(); } catch (IOException e) { e.printStackTrace(); } return str.toString(); } public static String readString(String path) { File file = new File(path); if (file.exists() && file.isFile()) { return readString(file); } return null; } }