469,317 Members | 1,977 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,317 developers. It's quick & easy.

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 25683
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
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.