In my program, I'm trying to read lines of strings from a text file and use StringTokenizer to store separate tokens into arrays. As you can see from my code below, I'm trying to store a line of string as tokens into the array fields by last name, first name, id, and password. This particular method code works in the general sense but I keep getting returned null values in my text file. Does anyone know what I'm doing wrong because everytime I execute the method, the outfile is completely erased because of the null. I caught the nullpointer exception but that doesn't solve my problem....The text file I'm reading from is attached.
amendClass[i] = new STUDENT(myLast, myFirst, myID, myPassword);
}
for(int i=8; i<44; i++)
{
// locate first non record and replace with new Student
if ((amendClass[i].myLast).equals("zzz"))
{
amendClass[i] = new STUDENT(myLast, myFirst, myID, myPassword);
i=46; // terminates loop
}
}
inFile.close();
// Great place to Sort Amended Array so that new student is
//in Alphabetical Order
STUDENT temp = new STUDENT("#","#","#","#");
for (int j = 8; j < amendClass.length - 1; j++)
{
for (int k = 8; k < amendClass.length-j-1; k++)
{
if ((amendClass[k].myLast).compareTo(amendClass[k + 1].myLast) > 0)
{
temp = amendClass[k];
amendClass[k] = amendClass[k + 1];
amendClass[k + 1] = temp;
}
}
}
FileOutput outFile = new FileOutput(myFileName); // Write changes to File
Bookmarks