Java tutorial
//package com.java2s; import android.content.Context; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class Main { /** * Read a file, used for reading weather file from assets * @param fileName * @param context * @return */ public static String readFromAssetsFile(String fileName, Context context) { StringBuilder returnString = new StringBuilder(); InputStream fIn = null; InputStreamReader isr = null; BufferedReader input = null; try { fIn = context.getResources().getAssets().open(fileName, Context.MODE_WORLD_READABLE); isr = new InputStreamReader(fIn); input = new BufferedReader(isr); String line = ""; while ((line = input.readLine()) != null) { returnString.append(line); } } catch (Exception e) { } finally { try { if (isr != null) { isr.close(); } if (fIn != null) { fIn.close(); } if (input != null) { input.close(); } } catch (Exception e2) { } } return returnString.toString(); } }