Android examples for App:Assets String
read Asset file To String
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.util.Scanner; import android.content.Context; public class Main { public static String readToString(Context ctx, String assetFilename) { InputStream in = null;//from w ww. ja va2 s . co m try { try { in = ctx.getAssets().open(assetFilename); // See: http://stackoverflow.com/a/5445161/614177 return new Scanner(in).useDelimiter("\\A").next(); } finally { if (in != null) { in.close(); } } } catch (IOException e) { throw new RuntimeException(e); } } }