input.txtMy text file is being stored into arrays so I can always use if myArray.length < x or if myArray.length > x to exit the system. However that doesn't seem to be working. Is there another way I'm not aware of that can let the user know the text file input is invalid before it crashes or exits the program?
800 1000 800
450 845 1200
1800 250 400
0 1500 1800
600 500 1000
700 1400 1700
675 400 900
String file = "input.txt";
String text = "";
double [] breakfast = new double [7];
double [] lunch = new double [7];
double [] dinner = new double [7];
try {
Scanner s = new Scanner(new File(file));
for (int i = 0;i<7;i++) {
breakfast[i] = s.nextInt();
lunch[i] = s.nextInt();
dinner[i] = s.nextInt();
if (breakfast.length == 0 || breakfast.length > 7 || breakfast.length < 7) {
System.out.println("Your file will not work with this program. Please select another.");
System.exit(0);
}