import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; public class TxtToArrayListDemo2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new FileReader("D:\Java\java作业\myCharStream\abc.txt")); ArrayListarray = new ArrayList (); String line; while ((line = br.readLine()) != null) { String[] strArray = line.split(","); Student student = new Student(); student.setSid(strArray[0]); student.setName(strArray[1]); student.setAge(Integer.parseInt(strArray[2])); student.setAddress(strArray[3]); array.add(student); } br.close(); for (Student student : array) { System.out.println(student.getSid() + "," + student.getName() + "," + student.getAge() + "," + student.getAddress()); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)