public static String pad(String str,int totalChars){
  if (str == null)   str="null";
  int slen=str.length();
  StringBuilder sb=new StringBuilder(str);
  for (int i=0; i < totalChars - slen; i++) {
    sb.append(" ");
  }
  return sb.toString();
}

public static String pad ( String str , int totalChars ) { if ( str == null ) str = "null" ; int slen = str . length ( ) ; StringBuilder sb = new StringBuilder ( str ) ; for ( int i = 0 ; i < totalChars - slen ; i ++ ) { sb . append ( " " ) ; } return sb . toString ( ) ; }
return a string of length a minimum of totalchars characters by padding the input string str with spaces . if str is already longer than totalchars , it is returned unchanged .
