Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList<Record> highScoreList;
- highScoreList = new ArrayList<>();
- highScoreReading(highScoreList);
- window.setOnCloseRequest(e -> {
- e.consume();
- highScoreSaving(highScoreList);
- window.close();
- });
- private void highScoreReading(ArrayList<Record> highScoreList){
- try{
- ObjectInputStream ois=new ObjectInputStream(new FileInputStream("highscore"));
- while(highScoreList.add((Record)ois.readObject())){/*semmi*/ }
- } catch (IOException io){
- } catch (ClassNotFoundException cnfe){
- }
- }
- private static void highScoreSaving(ArrayList<Record> highScoreList){
- //először rendezünk
- Collections.sort(highScoreList, new ScoreComparator());
- Collections.reverse(highScoreList);
- try {
- ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("highscore"));
- Iterator<Record> it = highScoreList.iterator();
- while(it.hasNext()){
- oos.writeObject(it.next());
- }
- } catch (IOException io){
- //vmi amivel lekezelem
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement