This should be really really simple, but for whatever reason…
String line;
String question = "";
Question qObj = new Question();
line = br.readLine(); //points to where i am in the file!
if (line == null){
System.out.println("There was no question here. ");
System.exit(1);
} else if (line.isEmpty() || line.trim().equals("") || line.trim().equals("\n")) {
// do nothing, i don't want empty lines
} else {
question = line;
}
while ((line = br.readLine())!= null){
if (line.indexOf(LoadFromDb.ANSWER_BEGIN) == 0){
dealWithAnswer(br, qObj);
qObj.setQuestion(question);
break;
} else {
if (!line.isEmpty()){
question += "\n" + line.trim();
}
}
If the first line the code above reads is just a blank line, then it adds the blank line to the line object, it doesn’t skip it. Any ideas why?
Regarding my response*, this is the kind of solution I was envisioning:
Although I’m sure there’s a more elegant way.
*
Setting question to line doesn't appear to change what line is read later (if you're wanting the line to advance before it hits the while loop