Here you can find the source of align(String key, int n)
static public String align(String key, int n)
//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; } }