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();
}
}
|
|