Java tutorial
//package com.java2s; import java.io.FileInputStream; import org.apache.http.util.EncodingUtils; public class Main { /** * @param fileName */ public static String readFileByLines(String fileName) { String res = ""; try { FileInputStream fin = new FileInputStream(fileName); int length = fin.available(); byte[] buffer = new byte[length + 1024]; fin.read(buffer); res = EncodingUtils.getString(buffer, "UTF-8"); fin.close(); } catch (Exception e) { e.printStackTrace(); } return res; } }