Java Error: NoSuchElementException
I'm new to java and trying to finish this program. Each time I run it I get a NoSuchElementException. I've included the portion of the code where the error seems to be happening. If anyone knows how to solve this problem that would be great.
Code:
import java.util.Scanner;
import java.io.*;
public class TackitMJL
{
public static void main(String[] args) throws IOException
{
PlainMJL plain;
RobotMJL r1, r2, r3, r4;
plain = new PlainMJL();
r1 = new RobotMJL();
r2 = new RobotMJL();
r3 = new RobotMJL();
r4 = new RobotMJL();
r1.setRobotStatus();
r2.setRobotStatus();
r3.setRobotStatus();
r4.setRobotStatus();
int flag = 0;
String whole_Line;
//Plain Size
int plain_Size;
//Bomb Locations
int bomb1_Location_X;
int bomb1_Location_Y;
int bomb2_Location_X;
int bomb2_Location_Y;
int bomb3_Location_X;
int bomb3_Location_Y;
int bomb4_Location_X;
int bomb4_Location_Y;
//Tackit Location
int tackit_Location_X;
int tackit_Location_Y;
Scanner fileScan, Scan;
fileScan = new Scanner (new File("Plain.dat"));
whole_Line = fileScan.nextLine();
Scan = new Scanner (whole_Line);
plain_Size = Scan.nextInt();
whole_Line = fileScan.nextLine();
Scan.useDelimiter(",");
bomb1_Location_X = Scan.nextInt(); <------ Console says error is here.
bomb1_Location_Y = Scan.nextInt();
whole_Line = fileScan.nextLine();
Scan.useDelimiter(",");
bomb2_Location_X = Scan.nextInt();
bomb2_Location_Y = Scan.nextInt();
Not sure if this helps, but the information that is in the plain.dat file is below:
Code:
100
5, 10
15, 25
6, 99
17, 3
12, 12