Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FileReader - returning null  RSS feed

 
Mike Philips
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm following a tutorial and I can't work out why the version that I have written is returning null when reading the text file...?



I can't see any difference in the code though, and the files being found in order for the null to appear... :?

the text file is within the Java project, and just has three lines :

line one
line two
line three


That's all it say..... But all my program returns is the work 'null'
 
Stephan van Hulst
Saloon Keeper
Posts: 7992
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike. Hint: You have a statement in your program that does absolutely nothing.
 
Mike Philips
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right... Where about's in the program?

I can't really follow the exceptions in try / catch, but the rest of the program seems to be doing stuff... The try / catch error's aren't appearing so I presume that they're being carried out without issue...

I seem to think that something's going wrong and that it's just printing out the value of br as assigned in line 13 - but I don't really get how or why that would happen.
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Line 25.
 
John M Morrison
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The semi on line 25 is decapitating your while loop.
 
Mike Philips
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah right, I haven't seen this before!

Cheers all
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!