public class Test5 {
//从文本文件中读取数据 一行是一个数据 存储到 集合中 并遍历
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("G:\\b.txt"));
ArrayList <String> list = new ArrayList<String>();
String s = null;
while ((s=br.readLine())!=null){
list.add(s);
br.close();
}
for (String string : list) {
System.out.println(string);
}
}
}
|
|