Java String Align align(String key, int n)

Here you can find the source of align(String key, int n)

Description

align

License

Open Source License

Declaration

static public String align(String key, int n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    static public String align(String key, int n) {
        return align(key, n, "");
    }//  w  ww  .jav  a  2  s .co  m

    static public String align(String key, int n, String suffixe) {
        int i = key.length();
        if (i >= n)
            return key + suffixe + " ";
        StringBuffer s = new StringBuffer();
        for (int j = 0; j < n - i; j++)
            s.append(' ');
        return key + suffixe + s;
    }
}

Related

  1. alignInTwoline(String data)