471,854 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,854 software developers and data experts.

skip blank line while reading text file

Hi ,
i am reading a text file with token # but somtimes blank lines comes between the line at blank line the code gives exception of no such element the text files contains data after blank lines
jatinder
Aug 29 '07 #1
2 26239
Nepomuk
3,112 Expert 2GB
Hi ,
i am reading a text file with token # but somtimes blank lines comes between the line at blank line the code gives exception of no such element the text files contains data after blank lines
jatinder
How are you reading the text? (File?) Sounds like, you have to check the current character for blank lines and skip them.
Aug 29 '07 #2
JosAH
11,448 Expert 8TB
Hi ,
i am reading a text file with token # but somtimes blank lines comes between the line at blank line the code gives exception of no such element the text files contains data after blank lines
jatinder
If you've just read a blank line repeat reading a next line again:

Expand|Select|Wrap|Line Numbers
  1. String line;
  2. while((line= bufreader.readLine()) != null)
  3.    if (line.trim().length() != 0)
  4.       return line;
  5.  
kind regards,

Jos
Aug 29 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by puzzlecracker | last post: by
16 posts views Thread by Adam Witney | last post: by
7 posts views Thread by elnoire | last post: by
NeoPa
reply views Thread by NeoPa | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.