guys, how could I parse a file that contains answers and questions in the form of:
Which of the following types are supertypes of Rectangle?
A) PrintStream
B) Shape
C) RectangularShape
D) Object
E) String
Select all that apply:
answer: BCD
my intent is to separate the question from the answer and put them both in an array that takes in question, answers, but I'm used to work with BufferedReader instead of Scanner which is the case here.... this is what I have so far, but is not doing the job
PHP Code:
public void read(Scanner in) throws IOException
{
String answers = "answer:";
while(in.hasNextLine())
{
while(in.nextLine())
if(!in.hasNext(answers))
{
q = in.nextLine();//getting the question
}
else
{
in.useDelimiter("answer:");
a = in.next();//getting the answer
}
addQuestion(new Question(q, a));
}