SHARE
TWEET

Untitled

davidtmi Jan 14th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top