I’m getting results from a database and want to output the data as a table in Java’s standard output
I’ve tried using \t but the first column I want is very variable in length.
Is there a way to display this in a nice table like output?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
System.out.format. You can set lengths of fields like this:This pads
string1,int1, andstring2to 32, 10, and 16 characters, respectively.See the Javadocs for
java.util.Formatterfor more information on the syntax (System.out.formatuses aFormatterinternally).