Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.io.File;
- import java.io.FileNotFoundException;
- public class BattleshipX {
- // Reads a file called fileName and loads a two-dimensional array called board with the file's contents
- public static void loadFile(char[][] board, String fileName) {
- try {
- Scanner file = new Scanner(new File(fileName));
- while (file.hasNextLine())
- for (int i = 0; i < file.length(); i++) {
- char spot = file.charAt(i);
- }
- System.out.println(file.nextLine());
- }
- }
- catch (FileNotFoundException exception) {
- System.out.println("Error opening file");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement