Computing.Net > Forums > Programming > Java programming help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Java programming help

Reply to Message Icon

Name: priti
Date: February 24, 2004 at 17:42:36 Pacific
OS: win 2000
CPU/Ram: p3
Comment:

Hi,
I'm trying to read file in java which contains blank lines in between.

I tried this one:

BufferedReader infile = new BufferedReader(new FileReader(file));
try {
// while ((i = infile.read()) != -1){
while ( (inLine = infile.readLine()) != null) {
System.out.println(inLine);
st = new StringTokenizer(inLine);
......}
File contains following format:
# dfafjk;kj
#;dfdjjk

#ldhldfdf
Abcedef
#

####
Bye!

I want to read whole file. When I try with above logic it gives me nullpointerexception after second line.
I want to go upto last line(Bye!).
So, my question is how can I read with text file with blank lines?
Thanks for help and time.




Sponsored Link
Ads by Google

Response Number 1
Name: priti
Date: February 24, 2004 at 18:53:11 Pacific
Reply:

Never mind. I figured it out.


0
Reply to Message Icon

Related Posts

See More


need help for script vb output alignment



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Java programming help

Please help with java program. www.computing.net/answers/programming/please-help-with-java-program/14834.html

Java Program Help www.computing.net/answers/programming/java-program-help/5365.html

need help w/ java programming www.computing.net/answers/programming/need-help-w-java-programming/9632.html