very new to java, just coming over from C++, so it's probably a very simple problem to fix but I can't find it.

the problem is occurring in this function:
public String getName(String id)
int codelength;
String delims = "[ ]+";
String[] temp = mainWindow.students;
String[] temp1 = new String[5];
for(int x = 0; x < temp.length; x++)
temp1 = temp[x].split(delims);// <-------------------------- NullPointerException
codelength = temp1[0].length();
if(temp[x].substring(0, codelength) == id)
return temp[x].substring(codelength, temp[x].length());
return "not found";

This function is meant to take String id and compare it to all of the codes in the mainWindow.students array, the codes being the first 5-8 lines of each string in the array separated by a space.
Then it returns the string when it finds a match.

I run the program, my window pops up, and when I attempt to use the part of the window that runs this function, I get a NullPointerException:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Attendance.inputHandler.getName( 24)

mainWindow.students is declared in the file right after the class declaration like this:
public class mainWindow extends JFrame
public static String[] students = new String[2000];

it is then filled like this:
FileReader input = new FileReader("Students.txt");
BufferedReader buffered = new BufferedReader(input);
String line = null;
int count = 0;
while((line = buffered.readLine()) != null)
students[count] = line;
catch(IOException e)

Not sure if this is too much information or too little but any help would be greatly appreciated, thanks in advance!