am trying to tell the program to always read in the file named, Competitors.txt but all I get is an error. i don't know what I am doing wrong here is my code.
Code:
import java.lang.*;
import java.util.*;
import java.io.*;
public class ContestManagement {
public static void main (String [] args) throws IOException{
//define local variables
final int MAX_LENGTH = 30;
Competitor competitorArray[] = new Competitor[MAX_LENGTH];
int arraySize = 0;
Scanner stdin = new Scanner(System.in);
//set up file stream
Scanner fileIn = null;
try {
fileIn = new Scanner("Competitors.txt");
for (int i = 0; (fileIn.hasNextLine()) && (i < MAX_LENGTH); ++i) {
int ID = fileIn.nextInt();
String n = fileIn.next();
double m = 0.0;
Competitor c = new Competitor(ID, n, m);
competitorArray[i] = c;
++arraySize;
}
}
catch (InputMismatchException e) {
System.out.println("uh oh, got an exception error!");
}
}
}
Comment