文件到集合(ArrayList)

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

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

/**
* FileName: TxtToArrayList
* Author: lps
* Date: 2022/3/26 17:32
* Sign:刘品水 Q:1944900433
*/
public class TxtToArrayList {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("F:\\JavaCode\\array.txt"));
ArrayList<Object> array = new ArrayList<Object>();
Object line;
while ((line= br.readLine())!=null){
array.add(line);
}

br.close();
for (Object o:array){
System.out.println(o);
}

}
}

 

posted @ 2022-03-26 17:43  刘品水  阅读(24)  评论(0编辑  收藏  举报