コード例 #1
0
 public static ArrayList<RecentGame> getSavedGames(Summoner summoner) throws Exception {
   ArrayList<RecentGame> ret = new ArrayList<RecentGame>();
   String gamesDirectory =
       String.format(
           gamesDirectoryFormat, ServerInfo.currentServerInfo.region, summoner.getSummonerID());
   for (File game : FileSystem.getFile(gamesDirectory).listFiles()) {
     if (!game.getName().equals("README")) {
       FileInputStream fis = new FileInputStream(game.getAbsolutePath());
       ObjectInputStream ois = new ObjectInputStream(fis);
       ret.add((RecentGame) ois.readObject());
       ois.close();
       fis.close();
     }
   }
   return ret;
 }
コード例 #2
0
 public static void save(RecentGame game, Summoner summoner) throws IOException {
   ObjectOutputStream objectOutputStream = null;
   RandomAccessFile raf = null;
   try {
     // TODO: write to XML or something instead of Java's silly format
     String gameFileString =
         String.format(
             gameFileFormat,
             ServerInfo.currentServerInfo.region,
             summoner.getSummonerID(),
             game.getGameID());
     raf = new RandomAccessFile(FileSystem.getFile(gameFileString), "rw");
     FileOutputStream fos = new FileOutputStream(raf.getFD());
     objectOutputStream = new ObjectOutputStream(fos);
     objectOutputStream.writeObject(game);
   } finally {
     if (objectOutputStream != null) {
       objectOutputStream.close();
     }
     if (raf != null) {
       raf.close();
     }
   }
 }