博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
创建文件流读取文件中的字符串
阅读量:4661 次
发布时间:2019-06-09

本文共 671 字,大约阅读时间需要 2 分钟。

public  String getUrl(){

File file=new File(mUrlPath);

String content="";

if(file.exists()){

InputStream instream;

try {

instream = new FileInputStream(file);

if (instream != null) 

            {

                InputStreamReader inputreader = new InputStreamReader(instream);

                BufferedReader buffreader = new BufferedReader(inputreader);

                String line;

                //分行读取

                while (( line = buffreader.readLine()) != null) {

                    content += line + "\n";

                }                

                instream.close();

            }

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

             

}

return content;

}

转载于:https://www.cnblogs.com/zhaolins/p/5682228.html

你可能感兴趣的文章