Exception in thread "main" java.lang.NullPointerException
hello,
i need help to sort out this runtime exception. This program is to extract the links present in the specified file. When i run this program i m getting one or two links and than this exception is comming.. Pls some one help. I have to run this on linux.
import java.io.*;
import java.lang.*;
import java.util.*;
class FileReadTest {
public static void main (String[] args) {
FileReadTest t = new FileReadTest();
t.readMyFile();
}
void readMyFile() {
String record = null;
int recCount = 0;
int index1,index2,cindex1,cindex2;
int count=0,flag1,flag2;
int least=1;
String history[];
history=new String[4];
String contin = null;
try {
FileReader fr= new FileReader("/tmp/dumpfile.txt");
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null) {
flag1=flag2 =0;
recCount++;
contin=new String();
index1=record.indexOf("Location");
cindex1=index1;
if(index1 != -1){
index1=index1+10;
contin=record.substring(index1);
// System.out.println(contin);
count++;
}//end if
index2=record.indexOf("Referer");
cindex2=index2;
if(index2 != -1){
index2=index2+9;
contin=record.substring(index2);
// System.out.println(contin);
count++;
}//end if
if(cindex1 != -1 || cindex2 != -1)
{
if(count<=4 && count != 0)
{if(count==1){
history[count-1]=contin;
System.out.println(contin);
}
else{
for(int i=0;i<count-1;i++)
{
if(history.equals(contin))
{
flag1 = 1;
}
}
}
}//end second if
else{
for(int i=0;i<4;i++)
{
if(history.equals(contin))
{
flag2 = 1;
}
}
}//end else
if(flag1 == 0 && flag2 == 0 && count != 1){
history[least]=contin;
least=least%3;
least++;
System.out.println(contin);
}
}//enf outermost if
}// end while
}
catch(IOException e) {
// catch possible io errors from readLine()
System.out.println("IOException error!");
e.printStackTrace();
}
} // end of readMyFile()
} // end of class>

