Posted
Filed under JSP, JAVA

public static String getSubStr(String _str, int _max){
 
  int int_byte        =        0;;
  String returnStr        =        "";
     
  for(int i=0 ; i<_max ; i++){
    String temp        =        "";
    temp        =        ""+_str.charAt(i);
    int_byte = int_byte+temp.getBytes().length;

    if(int_byte<=_max){
      returnStr        = returnStr+temp;       
    }else{
      break;
    }
 
  }
 
  return returnStr;
}

2011/03/11 13:07 2011/03/11 13:07