阅读背景:

如何从android studio上的txt文件中获取单行

来源:互联网 

My Code to get file content:

获取文件内容的我的代码:

private String readTxt(){

            InputStream inputStream = getResources().openRawResource(R.raw.text);

            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

            int i;
            try {
                i = inputStream.read();
                while (i != -1)
                {
                   byteArrayOutputStream.write(i);
                   i = inputStream.read();
                }
                inputStream.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return byteArrayOutputStream.toString();
        }
p



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: