安卓:assets目录下的文本文件(不受R文件节制)
时间:2016-05-09 18:44:40
收藏:0
阅读:180
try { InputStream in = getAssets().open("testAsset.txt"); byte[] buffer = new byte[1024]; int len = 0; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((len = in.read(buffer)) > 0) { baos.write(buffer, 0, len); } String str = new String(baos.toByteArray(), "GBK"); ZrLog.log(str); in.close(); } catch (IOException e) { e.printStackTrace(); }
原文:http://www.cnblogs.com/AndyHoo/p/5474632.html
评论(0)