有谁知道 Java 库或内置的我可以用来将数据格式化为适合打印到控制台的表格?
我知道使用 String.format 的字符串对齐和填充,但我正在寻找自动调整列宽以适应数据的东西,类似于column
BSD 系统上的命令。
您可以使用String.format
和Apache StringUtils.center()
自动填充文本以使其在单元格中居中:
https://commons.apache.org/lang/api-2.1/org/apache/commons/lang/StringUtils.html