首页 > 编程 > Java > 正文

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

2019-11-11 02:33:02
字体:
来源:转载
供稿:网友

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()整行的读取,当读到为空的时候停止


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表