Here you can find the source of loadTextFile(Context context, String textFile)
public static String loadTextFile(Context context, String textFile) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import android.content.Context; import android.content.res.AssetManager; public class Main { public static String loadTextFile(Context context, String textFile) throws IOException { AssetManager assetManager = context.getAssets(); InputStream inputStream = assetManager.open(textFile); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); StringBuilder stringBuilder = new StringBuilder(); String line = bufferedReader.readLine(); stringBuilder.append(line);/*from www. j a v a2s . c om*/ while (true) { if (isNullOrEmpty(line)) { break; } line = bufferedReader.readLine(); if (isNullOrEmpty(line) == false) { stringBuilder.append("\n"); stringBuilder.append(line); } } return stringBuilder.toString(); } public static boolean isNullOrEmpty(String input) { if (input == null) { return true; } return input.trim().isEmpty(); } }