I am writing a project in which I have to write questions and marks from MySQL database in a text file (Questions and marks are in different columns in database but in same table). Here, I want to write marks in same position i.e vertically aligned after each questions.
I tried using \t but it can't get desired output
while(myRs.next()) {
String question = myRs.getString("question");
String marks = myRs.getString("questionMarks");
try {
file.write(question+"\t\t\t\t\t\t\t" + marks + "\n");//write to text file
}
catch(Exception exe) {
System.out.println(exe);
}
System.out.println("Q" + count +". " + question);
}
Desired output is:
(Single "." represents whitespaces in actual output and "Question1", "Question2" , "Question3" are not actual questions, rather, they are statements)
Q1. Question1.............................4
Q2. Question2.............................4
Q3. Question3.............................5
Actual output is:
Q1. Question1........................ 4
Q2. Question2................................4
Q3. Question3...........................5