Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to skip an empty using regular expression in Java

807601Dec 6 2007 — edited Dec 6 2007
Hi all,

I read a text file line by line and I want to skip the empty line, which has no string at all(only space).Here is the code I use but it doesn't work.
I wonder if I use the right regular expression.

Thank you,
String line;
while((line=inputFile.readLine()!=null) &&line.matches("\\w+"))
{
   //do something here
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 3 2008
Added on Dec 6 2007
8 comments
530 views