private void gamesCsv(Round round) { File gamesCSV = new File(names[2]); if (gamesCSV.isFile() && gamesCSV.canRead()) { gamesCSV.delete(); } if (round.getSize() == 0) { return; } try { gamesCSV.createNewFile(); FileWriter fw = new FileWriter(gamesCSV.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write( "gameId;gameName;status;gameSize;gameLength;lastTick;" + "weatherLocation;weatherDate;logUrl;brokerId;brokerBalance;" + separator); String tourneyUrl = properties.getProperty("tourneyUrl"); String baseUrl = properties.getProperty("actionIndex.logUrl", "download?game=%d"); for (Game game : round.getGameMap().values()) { String logUrl = ""; if (game.isComplete()) { if (baseUrl.startsWith("http://")) { logUrl = String.format(baseUrl, game.getGameId()); } else { logUrl = tourneyUrl + String.format(baseUrl, game.getGameId()); } } String content = String.format( "%d;%s;%s;%d;%d;%d;%s;%s;%s;", game.getGameId(), game.getGameName(), game.getState(), game.getSize(), game.getGameLength(), game.getLastTick(), game.getLocation(), game.getSimStartTime(), logUrl); for (Agent agent : game.getAgentMap().values()) { content = String.format("%s%d;%f;", content, agent.getBrokerId(), agent.getBalance()); } bw.write(content + separator); } bw.close(); copyFile(gamesCSV, names[3]); } catch (IOException e) { e.printStackTrace(); } }