I am having a bit of trouble formatting an output file for myself to be easily readable. I am trying to output the file such as:
Name of School Size of School
-------------- --------------
Blblah blah 1300
Blah blah blah 11300
Blah blah blah asdf 14220
Blah bblah 1300
but am having trouble. Currently I am using the following code to get the following output:
File file1 = new File("src\\sortedInt.txt");
Formatter fmt = new Formatter(file1);
HelperMethods.quickSortStudents(colleges, 0, colleges.length - 1);
for(int i = 0; i < colleges.length; i++)
{
fmt.format(colleges[i].nameOfSchool + "%20d" + "\n", (int)colleges[i].numOfStudents);
fmt.flush();
}
which gives me:
eastman school of music 800
clark university 1100
walla walla college 1100
drew 1200
juilliard 1200
Because I am just padding from the end of the college name. Is there anyway to pad the whole string so all the strings are a constant length?
Thank you everyone for you help