Advertisement
davidtmi

Untitled

Jan 14th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.io.File;
  3. import java.io.FileNotFoundException;
  4.  
  5. public class BattleshipX {
  6.  
  7. // Reads a file called fileName and loads a two-dimensional array called board with the file's contents
  8. public static void loadFile(char[][] board, String fileName) {
  9. try {
  10. Scanner file = new Scanner(new File(fileName));
  11. while (file.hasNextLine())
  12. for (int i = 0; i < file.length(); i++) {
  13. char spot = file.charAt(i);
  14. }
  15. System.out.println(file.nextLine());
  16. }
  17. }
  18. catch (FileNotFoundException exception) {
  19. System.out.println("Error opening file");
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement