Deferred printing in Java

Posted by Bober02 on Stack Overflow See other posts from Stack Overflow or by Bober02
Published on 2012-03-31T17:19:13Z Indexed on 2012/03/31 17:29 UTC
Read the original article Hit count: 173

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about printing