Skip to content

java输出文本表格,类似于mysql命令行的结果集表格

Notifications You must be signed in to change notification settings

51gordon/jtext-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jtext-table

java输出文本表格,类似于mysql命令行的结果集表格,如下所示:


+---------+------+--------+
| name    | age  | income |
+---------+------+--------+
| tom     | 18   | 100    |
+---------+------+--------+
| cat     | 26   |        |
+---------+------+--------+
| 奥巴马儿 | 250  | 0      |
+---------+------+--------+

使用方法如下所示,new一个TextTable,传递header和行数据,调用toString方法输出即可:


public class TestMain {
  public static void main(String[] args) {
    String[] header = {"name", "age", "income"};
    String[][] rows = {
        {"tom", "18", "100"},
        {"cat", "26", null},
        {"奥巴马儿", "250", "0"}
    };
    System.out.println(new TextTable(header, rows));
  }
}

About

java输出文本表格,类似于mysql命令行的结果集表格

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages