Any Java libraries for drawing ASCII tables?

前端 未结 4 901
北恋
北恋 2021-02-01 19:44

I need to output data into a console as a table. I was wondering maybe there are some java libraries that would take care of drawing tables in ASCII art, aligning values inside

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 20:30

    Here is also a handy library: https://github.com/JakeWharton/flip-tables

    As the doc said:

    String[] headers = { "Test", "Header" };
    String[][] data = {
        { "Foo", "Bar" },
        { "Kit", "Kat" },
    };
    System.out.println(FlipTable.of(headers, data));
    

    should have the following output:

    ╔══════╤════════╗
    ║ Test │ Header ║
    ╠══════╪════════╣    
    ║ Foo  │ Bar    ║
    ╟──────┼────────╢
    ║ Kit  │ Kat    ║
    ╚══════╧════════╝
    

提交回复
热议问题