public String leftStr(String str,int length){
  return str.substring(0,Math.min(str.length(),length));
}

public String leftStr ( String str , int length ) { return str . substring ( 0 , Math . min ( str . length ( ) , length ) ) ; }
returns a substring of the given string , representing the ' length ' most - left characters
