黑马程序员技术交流社区
标题:
学习笔记
[打印本页]
作者:
heqinghui
时间:
2019-10-17 15:08
标题:
学习笔记
public class
Test1Demo {
public static void
main(String[] args)
throws
IOException {
BufferedReader br =
new
BufferedReader(
new
FileReader(
"emInfo.txt"
));
List<Employee> list =
new
ArrayList<>();
String line;
while
((line = br.readLine()) !=
null
) {
Employee em =
new
Employee();
String[] s = line.split(
"-"
);
em.setName(s[
0
]);
em.setSsbm(s[
1
]);
em.setZw(s[
2
]);
em.setSex(s[
3
]);
list.add(em);
}
BufferedWriter bw =
new
BufferedWriter(
new
FileWriter(
"info.txt"
));
bw.write(
"研发部人员有:"
);
for
(Employee e : list) {
if
(e.getSsbm().equals(
"研发部"
)){
bw.write(e.getName()+
" "
);
bw.flush();
}
}
br.close();
bw.close();
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2