Java tutorial
//package com.java2s; /* LICENSE * This work is licensed under the * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. * To view a copy of this license, visit * http://creativecommons.org/licenses/by-nc-sa/3.0/. * * Copyright (c) 2013 by Laurent Constantin <constantin.laurent@gmail.com> */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import android.content.Context; public class Main { /** * Load an asset file and return file's content * * @param mContext Context * @param mFilename filename * @return file's content */ private static String loadFileText(final Context mContext, final String mFilename) { try { StringBuffer mFileData = new StringBuffer(); final BufferedReader mReader = new BufferedReader( new InputStreamReader(mContext.getAssets().open(mFilename))); String line; while ((line = mReader.readLine()) != null) { mFileData.append(line); } return mFileData.toString(); } catch (IOException e) { return null; } } }