Java-基础 文件操作IO-读取文件内容

来源:互联网 发布:淘宝客户vip设置 编辑:程序博客网 时间:2024/05/17 08:23

public static void main(String[] args)  {
        try {
            BufferedReader in = new BufferedReader(new FileReader("wangaw.txt"));
            String str;
            while ((str = in.readLine()) != null) {
                System.out.println(str);
            }
            System.out.println(str);
        } catch (IOException e) {
        }
    }

读取文件的内容

in.readLine()整行的读取,当读到为空的时候停止


0 0
原创粉丝点击