Java: how to tell if a line in a text file was supposed to be blank?

Posted by defn on Stack Overflow See other posts from Stack Overflow or by defn
Published on 2010-03-09T00:55:35Z Indexed on 2010/03/09 1:21 UTC
Read the original article Hit count: 291

I'm working on a project in which I have to read in a Grammar file (breaking it up into my data structure), with the goal of being able to generate a random "DearJohnLetter".

My problem is that when reading in the .txt file, I don't know how find out whether the file was supposed to be a completely blank line or not, which is detrimental to the program.

Here is an example of part of the file, How do i tell if the next line was supposed to be a blank line? (btw I'm just using a buffered reader) Thanks!


<start>
I have to break up with you because <reason> . But let's still <disclaimer> .

<reason>
<dubious-excuse>
<dubious-excuse> , and also because <reason>

<dubious-excuse>
my <person> doesn't like you
I'm in love with <another>
I haven't told you this before but <harsh>
I didn't have the heart to tell you this when we were going out, but <harsh>
you never <romantic-with-me> with me any more
you don't <romantic> any more
my <someone> said you were bad news

© Stack Overflow or respective owner

Related posts about context-free-grammar

Related posts about grammars