Android ~ get Assets file content

the order.html is in the assets folder, assets/order.html
------------------------------------------------------------------------------------------
AssetManager assets = getAssets();
try {
InputStream is2 = assets.open("order.html");

BufferedReader in = new BufferedReader(new InputStreamReader(is2));
StringBuffer buffer = new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
buffer.append(line);
buffer.append("\n");
}

Log.i("yyyy", buffer.toString());

} catch (Exception e) {
Log.i("xxxx", "failed");
}

------------------------------------------------------------------------------------------

reference
http://eppleton.sharedhost.de/blog/?p=183

沒有留言: