ランダムな「DearJohnLetter」を生成できるようにすることを目標に、Grammar ファイルを読み込む (データ構造に分割する) 必要があるプロジェクトに取り組んでいます。
私の問題は、.txt ファイルを読み取るときに、ファイルが完全に空白の行であると想定されているかどうかを確認する方法がわからないことです。これは、プログラムにとって有害です。
ファイルの一部の例を次に示します。次の行が空白行であるかどうかを確認するにはどうすればよいですか? (ところで、私はバッファリングされたリーダーを使用しています)ありがとう!
<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