A simple paragraph

This example shows how to create a table, add content (rows and cells), and render the table. It also demonstrates that all excessive white spaces (extra blanks, tabulators, new lines) will be removed automatically. Furthermore, the table will break lines automatically to the set width (in the example the default width of 80 characters). This automatic line break uses words (not characters).

1
2
3
4
5
6
7
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("row 1 col 1", "row 1 col 2");
at.addRule();
at.addRow("row 2 col 1", "row 2 col 2");
at.addRule();
System.out.println(at.render());

The resulting output:

┌───────────────────────────────────────┬──────────────────────────────────────┐
│row 1 col 1                            │row 1 col 2                           │
├───────────────────────────────────────┼──────────────────────────────────────┤
│row 2 col 1                            │row 2 col 2                           │
└───────────────────────────────────────┴──────────────────────────────────────┘