本着身为菜鸡程序员就偷懒的原则,班上收作业,清理名单很麻烦,那就用刚学的java写个清理名单的程序,辅导员再也不怕我收不齐作业了,废话不多讲开始吧!
导包:
import java.io.*;//需要用到文件 import java.util.HashMap;//容器 import java.util.Iterator;//迭代器
功能实现
public class Read {
public static void main(String[] args) {
File subDriv = new File("E:\desk\名单");//读取需要筛选的名单
String[] subName = subDriv.list();//读取文件夹里的子文件
HashMap houseWare = new HashMap<>();//创建一个小容器对象,具体到某一个同学,key = 同学名,value = 交没交作业;
String[] container = new String[43]; //大容器,相当于一个教室,装下每一个同学
File nameList = new File("src//name.txt");//读取所有的同学的名单
try {
BufferedReader reader = new BufferedReader(new FileReader(nameList));
String temp = reader.readLine();//读取名单
int k=0;
while (temp!=null){
container[k++] = temp;
temp = reader.readLine();//将名单写入数组
}
} catch (Exception e) {
e.printStackTrace();
}
for(int m = 0;m 


