如何创建Eclipse Java中分隔的制表符

时间:2013-10-24 08:48:43

标签: java tabs delimited

我试图通过为每个列结果提供一个好的选项卡来使我的结果看起来很好。 这是我的toString()函数。我在stackoverflow中搜索了这个问题,但它没有回答我的问题。我在Eclipse Java中找不到StringUtils.rightPad(String,int)实用程序。我应该下载任何包裹还是其他任何东西?

         public String toString(){
        StringBuffer sb = new StringBuffer(150);
        sb.append(getDept(department));
        sb.append("\t");
        sb.append(getName());
        sb.append("\t");
        sb.append(getAge());
        sb.append("\t");
        sb.append(checks.check());

        return sb.toString();
    }


Here's my result using ("\t") :

Department      Name    Age Prime
__________________________________________________
Information_Systems Hacking Novice  23  true
Accounting  Counting Novice 25  false
Marketing   Sales Savvy 38  false
Information_Systems Hacking Savvy   38  false
Accounting  Counting Savvy  40  false
Accounting  Counting Pro    45  false
Information_Systems Hacking Pro 46  false
Human_Resources Hiring Pro  47  true
Marketing   Sales Pro   48  false
Marketing   Sales Guru  50  false
Information_Systems Hacking Guru    51  false
Accounting  Counting Guru   55  false
Human_Resources Hiring Guru 58  false

1 个答案:

答案 0 :(得分:1)

org.apache.commons.lang.StringUtils.rightPad(String, int)

Download Commons Lang