因此,由于某种原因,在我的 while 循环中有一个 try catch,当 catch 触发时,由于某种原因,catch 块之后的代码仍在执行,并在 catch 块内使用 continue 语句。所以我不知道发生了什么。
ArrayList<File> mapFileList = new ArrayList<File>();
HashMap<String,Map> mapHash = new HashMap<String,Map>();
// Player Variables
ArrayList<Player> playerList = new ArrayList<Player>();
Iterator<Player> playerIter;
HashMap<String,Stats> statsMap = new HashMap<String,Stats>();
File playerStatsFile;
File newPlayerStatsFile;
/*
* Choose a map or make a new one
*/
// Make a list of all existing files
File mapFolder = new File("bin/maps/");
// If the maps folder does not already exist, make it
if(mapFolder.mkdir()){
System.out.println("Maps folder does not exist. Creating.");
}
// For ever map file in the directory, save it to the map file list
for(File fMap : mapFolder.listFiles()){
if(fMap.getName().endsWith(".map")){
mapFileList.add(fMap);
}
}
// Load those maps into the mapHash HashMap
Iterator<File> itMap = mapFileList.iterator();
while(itMap.hasNext()){
Map map = null;
File fMap;
// Get each map
fMap = itMap.next();
// Load them into memory and deserialize the map
try{
MapReader.openFile(fMap);
}catch(IOException e){
System.out.println("Error: Cannot open file.");
continue;
}
try{
map = MapReader.readRecords();
}catch(Exception e){
System.out.println("Error: Problem with reading the map.");
//System.exit(1);
continue;
}
// Let the user know the map loaded successfully
System.out.println("Map "+map.getName()+" loaded.");
// Then store the map into the mapHash
mapHash.put(map.getName().toLowerCase(), map);
}