Here you can find the source of getfromAssets(Context ctx, String file_name)
public static String getfromAssets(Context ctx, String file_name)
//package com.java2s; import android.content.Context; import android.content.res.AssetManager; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { /**/*from ww w .j a v a2 s . c o m*/ * Read a file from assets * * @return the string from assets */ public static String getfromAssets(Context ctx, String file_name) { AssetManager assetManager = ctx.getAssets(); ByteArrayOutputStream outputStream = null; InputStream inputStream = null; try { inputStream = assetManager.open(file_name); outputStream = new ByteArrayOutputStream(); byte buf[] = new byte[1024]; int len; try { while ((len = inputStream.read(buf)) != -1) { outputStream.write(buf, 0, len); } outputStream.close(); inputStream.close(); } catch (IOException e) { } } catch (IOException e) { } return outputStream.toString(); } }