java实现文件的读取并存入不同的数组中 想要代码,自己也知道用io,可是不太会呀!姓名和号码用空格区分 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用list吧,数组你提前知道多大吗?不然会越界的! FileReader fr = null; BufferedReader br = null; List<String> nameList = new ArrayList<String>(); List<String> phoneList = new ArrayList<String>(); try { fr = new FileReader(new File("H:\\test.txt")); br = new BufferedReader(fr); String line = null; String[] strs = null; while ((line = br.readLine()) != null) { strs = line.split("\\s+"); nameList.add(strs[0]); phoneList.add(strs[1]); } } catch (Exception e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } if (fr != null) { try { fr.close(); } catch (IOException e) { e.printStackTrace(); } } } struts2在action中调用ActionContext.put()将属性添加到request 代码提交的时间与CVS上的时间不一致问题 struts2中使用servlet关于web.xml的配置 系统要为第三方留接口,这个怎么做的? 跟换验证码 struts2一点小问题 关于frame的问题 CXF客户端动态调用webservice问题 weblogic 7.0 运行问题?? 想高手请教--急+郁闷!!! 关于weblogic 7的问题,已经困扰我几天了!!!!!!!!!! Tigase客户端Jaxmpp群聊如何实现 tomcat的work线程占用大量cpu
BufferedReader br = null;
List<String> nameList = new ArrayList<String>();
List<String> phoneList = new ArrayList<String>();
try {
fr = new FileReader(new File("H:\\test.txt"));
br = new BufferedReader(fr);
String line = null;
String[] strs = null;
while ((line = br.readLine()) != null) {
strs = line.split("\\s+");
nameList.add(strs[0]);
phoneList.add(strs[1]);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fr != null) {
try {
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}