Question

I'm trying to make my result looks good by having a good tab for each column result. Here's my toString() function. I searched for this problem in stackoverflow, but it doesn't answer my question. I can't find the StringUtils.rightPad(String, int) utilities in Eclipse Java. Should I download any package or anything?

         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
Was it helpful?

Solution

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

Download Commons Lang

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top