Deferred printing in Java
- by Bober02
I have a specific issue with general console printing and I was wondering whether anyone has a solution for it. I am trying to print a dataTable which would look like sth like this:
Table
----------------------
Name |Surname |
----------------------
Mike |Mikhailowish|
Rafaello|Mirena |
and so on. In order to print the border of the bar I need to know what the maximum length of each column value is. I don't want to go through the whole database to find that out and then again to print it. I would rather like to do sth like:
System.out.printLater(s); //herejust leave a pointer to a StringBuilder you will build
...
s.append("--------");
...
System.out.printAllDeferred();
I understand the above is probably in 99.99999% chances impossible, but perhaps you guys have a clever way of achieving the above?