public static String left(String str,int count){
  if (str == null) {
    return null;
  }
  if (str.length() < count) {
    return str;
  }
  return str.substring(0,count);
}

public static String left ( String str , int count ) { if ( str == null ) { return null ; } if ( str . length ( ) < count ) { return str ; } return str . substring ( 0 , count ) ; }
returns the first n characters from this string , where n = count . if the string is shorter , the entire string will be returned . if the string is longer , it will be truncated .
