Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.http.util.EncodingUtils; import android.util.Log; public class Main { private static final String FILE_ENCODING = "utf-8"; /** * (java) read from file * * @param path * @return */ public static String readFile(File file) { String str = ""; FileInputStream in; try { in = new FileInputStream(file); int length = (int) file.length(); byte[] temp = new byte[length]; in.read(temp, 0, length); str = EncodingUtils.getString(temp, FILE_ENCODING); in.close(); } catch (IOException e) { Log.e("", "read error!"); } return str; } }