I need to read a text file that looks something like this
8 7 ~~~~~~~ ~~~~~~~ B~~~~~~ ~~~~~~~ ~~~~B~~ ~~~~B~~ ~~~~~~B ~~~~~~~ ~~~~~~~ My program is recreating a Battleship game. I need to accept the values 8 and 7 but only print from the second line down. I'm supposed to use string.split (i believe). I need to print only the lines with ~'s and B's. I have the code already for reading the file, I'm just unsure how to split the file by line breaks.
File file = new File(args[1]); try { Scanner sc = new Scanner(file); while (sc.hasNextLine()) { String themap = sc.nextLine(); System.out.println(themap); } sc.close(); } catch (Exception e) { System.out.println("ERROR: File does not exist"); }