Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. private static void saveToFile(LeaderBoard playerScore){
  2.         StringJoiner joiner = new StringJoiner("|");
  3.         joiner.add(playerScore.playerName)
  4.                 .add(playerScore.date)
  5.                 .add(playerScore.guessTime)
  6.                 .add(playerScore.guessTries)
  7.                 .add(playerScore.word)
  8.                 .add("\n");
  9.  
  10.         String joinedString = joiner.toString();
  11.         try (PrintWriter out = new PrintWriter(new FileOutputStream(new File ("highscores.txt"), true));){
  12.             out.append(joinedString);
  13.         }catch(Exception e){
  14.             System.out.println("File not found :( ");
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement