it just skips the for loop ... How come it is saying one question when i have 10 questions?
Back to the
while loop in the three
readFileXXX methods in which you do not save the data you are reading from the file into the StringBuilder.
try {
while (true) {
// Here you are saving the read input in the "desc" variable but
// you do not add it ("desc") to the StringBuilder. So when the
// StringBuilder is returned as a string it will be empty.
desc = in.readUTF();
// Need to add the newly-read data to the StringBuilder:
sb.append(desc + separator);
}
} catch (EOFException e) { }
To test/explore this idea/suggestion try adding a print statement at the beginning of the
askQusestions method to check the incoming arguments, like this:
private void askQuestions(String[] questions, String[] answers) {
System.out.printf("questions = %s%nanswers = %s%n", // debugging
Arrays.toString(questions),
Arrays.toString(answers));