Andy 胡

导航

安卓:assets目录下的文本文件(不受R文件节制)

        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();
        }

 

posted on 2016-05-09 17:04  talkwah  阅读(249)  评论(0编辑  收藏  举报