首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

怎么把逐行读取的数据保存到对象中

2012-09-10 
怎样把逐行读取的数据保存到对象中File f new File(file)try {FileReader fr new FileReader(f)Buff

怎样把逐行读取的数据保存到对象中
File f = new File(file); 
try {
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String line = null;
while((line = br.readLine())!=null){

System.out.println(line);

}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

结果能读取出这样有规律的文件
-----------------------------------------------------
朝阳区
车龙汽车装饰(望京店)
南湖西园502号院中广宜景湾底商
4000052365
null
8:30-18:30
39.904214, 116.40741300000002

昌平区
京杰汽车服务
文华路龙锦苑四区2号楼底商
010-81746257
null
尚无营业时间
40.0822929, 116.34415969999998
-------------------------------------------------------
怎样在while循环中把每行数据付给对象的属性

[解决办法]

探讨

呵呵 终于搞定了

热点排行