关于readLine()的小问题

peng658890 peng658890 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
try {
fr=new FileReader("d:\\1.txt");
br=new BufferedReader(fr);
String n="";
//先读取第一行
n=br.readLine();
allEnNum=Integer.parseInt(n);
while(br.readLine()!=null)
{
String []xyz=br.readLine().split(" ");
Node node=new Node(Integer.parseInt(xyz[0]), Integer.parseInt(xyz[1]), Integer.parseInt(xyz[2]));
nodes.add(node);
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}finally{
try {
br.close();
fr.close();
} catch (Exception e2) {
e2.printStackTrace();
// TODO: handle exception
}
}

文本文档里有3行数据 为什么就只读到了一行呢 难道说只要出现readLine()就会去读一行 不赋值给n也算进去?
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
peng658890
Java SE 62,621 成员 307,251 内容