Forums Register Login

Blank lines in file throwing exception

+Pie Number of slices to send: Send
Happy Holidays! The problem is the program works just fine until it hits a blank line. Then the jvm takes up 99% of my resources and the my gui locks on my screen. Sry for the long code, but figure it'll be easier to diagnose.
tried if(inputLine.equals("")continue; and if(inputLine.equals("")inputLine = reader.readLine(); no avail

[ December 28, 2003: Message edited by: Tony Fabeets ]
+Pie Number of slices to send: Send
 

Originally posted by Tony Fabeets:


When you hit a blank line, you get an endless loop.
+Pie Number of slices to send: Send
Good catch, Joe! This is common practice:

This takes advantage of the fact that in Java an assignment clause (line = something) is a function. That is, it not only assigns a value to a variable, but returns that value, too. So in one swell foop we can read a line, check it for null and terminate the loop. With this in place, your "continue" clause will skip the rest of the loop and read another line.
+Pie Number of slices to send: Send
It's still blowing up on the empty line, no matter what i try... help please?

.equals("\r") fixed the prob
[ December 24, 2003: Message edited by: Tony Fabeets ]
[ December 24, 2003: Message edited by: Tony Fabeets ]
[ December 24, 2003: Message edited by: Tony Fabeets ]
His brain is the size of a cherry pit! About the size of this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1464 times.
Similar Threads
Client-Server Problem
tokenizer throwing NullPointerException
Removing multiline comments
How to read a .txt file and open its contents
travel agent - java writing to file via user input
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:02:46.