Here you can find the source of Readfile(String path)
public static String Readfile(String path)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; public class Main { public static String Readfile(String path) { try {// w w w . java 2s.co m StringBuffer readsb = new StringBuffer(); InputStream in = new FileInputStream(new File(path)); ArrayList<String> alist = new ArrayList<String>(); int count; byte[] b = new byte[1024 * 1024]; while ((count = in.read(b)) != -1) { if (count != b.length) { byte[] t = new byte[count]; for (int i = 0; i < count; ++i) t[i] = b[i]; readsb.append(new String(t)); } else readsb.append(new String(b)); } in.close(); return readsb.toString(); } catch (Exception ex) { ex.printStackTrace(); return null; } } }