码迷,mamicode.com
首页 > 编程语言 > 详细

java按行读取文件

时间:2016-04-01 09:03:56      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

  /**
     * 按流读取文件
     * @param path
     * @return
     * @throws FileNotFoundException
     */
    public static BufferedReader openFile(final String path) throws FileNotFoundException {
        FileInputStream in = new FileInputStream(new File(path));
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));

        return reader;
    }

一行一行的读取:

read.readLines();

 注意:这里返回的不是数组,而是字符串。

java按行读取文件

标签:

原文地址:http://www.cnblogs.com/yrqiang/p/5343649.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!