I'm hoping this is the right place for posting my question. This is the error I'm getting in my code...
jani@ani-desktop:~/Desktop/FINAL-UTILITIES$ java retrievalGabor single-image/0000.jpg single-image-gabor-query.txt featdb.txt gabdb.txt 1 gaGabor-output.txt qt
1
gaGabor-output.txt
im here
java.lang.NullPointerException at retrievalGabor.main(retrievalGabor.java:90)
java code here
//The alignment of the features is assumed to be AVG, VAR, CSD, GABOR
System.out.println(args[5]);
dis1=new DataInputStream(new FileInputStream(args[5]));//opening the relevant features file
System.out.println("im here");
}
else
dis1=new DataInputStream(new FileInputStream(args[4]));//opening the relevant features file
//query=myFinalToolkit.computeColorSampleImage(bi, BLOCKS, SCALE*ORIENTATION);
//query= new float[126];
//sort the entries in the sorted order
for(int i=0;i<images-1;i++)
for(int j=0;j<images-i-1;j++)
{
if(diff[j+1]<diff[j])
{
tmp=diff[j];
diff[j]=diff[j+1];
diff[j+1]=tmp;
/* //sort the entries in the sorted order by name
for(int i=0;i<29;i++)
for(int j=0;j<29-i;j++)
{
if(names[j].compareTo(names[j+1])>0)
{
tmp=diff[j];
diff[j]=diff[j+1];
diff[j+1]=tmp;
the following is the error :
ani@ani-desktop:~/Desktop/FINAL-UTILITIES$ java retrievalGabor single-image/0000.jpg single-image-gabor-query.txt featdb.txt gabdb.txt 1 gaGabor-output.txt qt
1
gaGabor-output.txt
im here
java.lang.NullPointerException at retrievalGabor.main(retrievalGabor.java:90)
java code here:
/The alignment of the features is assumed to be AVG, VAR, CSD, GABOR
In the main() method of the retrievalGabor class at line 90 of the retrievalGabor.java file is the offending line. Add a few debugging messages of the variables used in the line to find the null pointer.
That's still essentially illegible. Consider (a) indenting your code, (b) splitting long lines so we don't have to right-scroll a few screens, and (c) writing a method or two.
Is the NPE coming from the readline().split(" ") call?
According to the API, java.io.BufferedReader.readLine() will return null if the end of the stream has been reached, in which case tokens=(br.readLine()).split(" "); would throw an NPE since you can't call split a null.
In addition to David Newton's formatting concerns, I'm worried that 230 lines of code have been written without individually testing any of it. A beginner should write 5 lines of code, test it thoroughly, and then write 5 more (use methods). I'm sorry if I'm wrong and that's exactly what you've done, but that's not how it looks.
David Sharpe wrote:According to the API, java.io.BufferedReader.readLine() will return null if the end of the stream has been reached, in which case tokens=(br.readLine()).split(" "); would throw an NPE since you can't call split a null.
In addition to David Newton's formatting concerns, I'm worried that 230 lines of code have been written without individually testing any of it. A beginner should write 5 lines of code, test it thoroughly, and then write 5 more (use methods). I'm sorry if I'm wrong and that's exactly what you've done, but that's not how it looks.
I would argue that EVERYONE should test like that, not just beginners.
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.