I would like to create beautifully formatted tabular text from arbitrary models of dataset objects. Is there a good library for this in Java?
In particular, I need output that is formatted as command line data management tools such as the CLI for mysql. Example:
+---------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+-------+ | name | varchar(100) | YES | | NULL | | | release | year(4) | YES | | NULL | | | studio | varchar(50) | YES | | NULL | | | review | varchar(50) | YES | | NULL | | | gross | int(11) | YES | | NULL | | +---------+--------------+------+-----+---------+-------+
One of the main problems is that I will not automatically know the maximum column widths before I start crawling the data. In addition, there are many edge cases, such as handling very large lengths of values ββand a large number of rows and columns.
If I need to build this on my own, I assume that I will use String.format, and I will need to pre-analyze the complete data set before starting the output. This is a very low level of coding, so I would like to find a good library that has already solved this problem.
java formatting text
dirtyvagabond
source share