Advertisement
Guest User

Untitled

a guest
Mar 17th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package pl.snake.score;
  2.  
  3. import java.io.*;
  4.  
  5. public class Score{
  6. public static DataInputStream fileInput = null;
  7. public static DataOutputStream fileOutput = null;
  8.  
  9. public static void onLoad(){
  10. File file = new File("score.txt");
  11. try{
  12. if(!file.exists())
  13. file.createNewFile();
  14. fileInput = new DataInputStream(new FileInputStream(file));
  15. fileOutput = new DataOutputStream(new FileOutputStream(file));
  16. } catch(FileNotFoundException e){
  17. e.printStackTrace();
  18. } catch(IOException e){
  19. e.printStackTrace();
  20. }
  21. }
  22. public static int onRead(){
  23. int score = 0;
  24. try {
  25. score = fileInput.readInt();
  26. } catch (IOException e) {
  27. e.printStackTrace();
  28. }
  29. return score;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement