Here you can find the source of readFile(String filePath, String charsetName, long lineNow, long lineEnd)
public static String readFile(String filePath, String charsetName, long lineNow, long lineEnd)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; public class Main { public static String readFile(String filePath, String charsetName) { StringBuffer sb = new StringBuffer(); BufferedReader br = null; try {/*from w w w . j a v a2s . c o m*/ br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), charsetName)); String data = null; while ((data = br.readLine()) != null) { sb.append(data); sb.append("<br/>"); } } catch (Exception e) { } finally { try { br.close(); } catch (Exception e) { } } return sb.toString(); } public static String readFile(String filePath, String charsetName, long lineNow, long lineEnd) { StringBuffer sb = new StringBuffer(); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), charsetName)); String data = null; int i = 0; while ((data = br.readLine()) != null) { if (i <= lineEnd && i >= lineNow) { sb.append(data); sb.append("<br/>"); } i++; } } catch (Exception e) { } finally { try { br.close(); } catch (Exception e) { } } return sb.toString(); } }