public static String appendWhitespaceOrTrim(String s,int length){
  if (s == null) {
    s=new String("");
  }
  int retLength=s.length();
  if (retLength < length) {
    StringBuffer sb=new StringBuffer(s);
    int numWhites=length - retLength;
    for (int i=0; i < numWhites; i++) {
      sb.append(" ");
    }
    s=sb.toString();
  }
 else   if (retLength > length) {
    s=s.substring(0,length);
  }
  return s;
}

public static String appendWhitespaceOrTrim ( String s , int length ) { if ( s == null ) { s = new String ( "" ) ; } int retLength = s . length ( ) ; if ( retLength < length ) { StringBuffer sb = new StringBuffer ( s ) ; int numWhites = length - retLength ; for ( int i = 0 ; i < numWhites ; i ++ ) { sb . append ( " " ) ; } s = sb . toString ( ) ; } else if ( retLength > length ) { s = s . substring ( 0 , length ) ; } return s ; }
a method that looks at the length of string s and returns a copy of it with whitespace appended to the end to allow it to have the provided length .
