Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public static void main(String[] args) throws Exception {
  2. 06
  3. // Create a File instance
  4. 07
  5. java.io.File file = new java.io.File("scores.txt");
  6. 08
  7.  
  8. 09
  9. // Create a Scanner for the file
  10. 10
  11. Scanner input = new Scanner(file);
  12. 11
  13.  
  14. 12
  15. // Create the Content String
  16. 13
  17. String fileContent = "";
  18. 14
  19.  
  20. 15
  21. // Read data from a file
  22. 16
  23. while (input.hasNext()) {
  24. 17
  25. fileContent += input.next() + " ";
  26. 18
  27. }
  28. 19
  29. // Close the file
  30. 20
  31. input.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement