其他分享
首页 > 其他分享> > 文件到集合ArrayLsit改进版本

文件到集合ArrayLsit改进版本

作者:互联网

package com.czie.iot1913.lps.IO.BufferStream;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

/**
* FileName: TxtToArrayList01
* Author: lps
* Date: 2022/3/26 18:34
* Sign:刘品水 Q:1944900433
*/
public class TxtToArrayList01 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("F:\\JavaCode\\array.txt"));
ArrayList<Students> array = new ArrayList<>();
String line;
while ((line= br.readLine())!=null) {
String[] strArray = line.split(",");
Students s1 = new Students();
s1.setNumber(strArray[0]);
s1.setName(strArray[1]);
s1.setAge(Integer.parseInt(strArray[2]));
s1.setLiveofplace(strArray[3]);
array.add(s1);
}
br.close();
for (Students s:array){
System.out.println(s);
}

}
}

 

标签:java,ArrayLsit,s1,strArray,版本,new,集合,import,array
来源: https://www.cnblogs.com/lps1944900433/p/16060357.html