I have a list that looks similar to thisand is stored in a text file;
last, first, code
smith, john, test
I cannot figure out why it is out of bounds. Where am I going wrong? is it in the split statement?
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.Scanner;
public class FileHandling {
static String[] className;
static String[][] classList;
static int counter = 0;
public static void main(String args[]){
className = new String[100];
try{
FileInputStream fstream = new FileInputStream("classNames.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
className[counter]=strLine;
counter+=1;
}
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}//end try/catch
int i=0;
int num=0;
classList = new String[100][4];
while(num<counter){
while (i<3){
String tempData[] = className[num].split("(?<!\\\\),");
classList[num][i]=tempData[i];
i+=1;
}
i=0;
num+=1;
}//end while
menuSelect();
}//end method