티스토리 뷰

카테고리 없음

cutString

[czar] 2010. 5. 19. 21:28

public static String cutString(String str, int len) { 

  byte[] by = str.getBytes();
  int count = 0;
  try  {
   for(int i = 0; i < len; i++) {
    if((by[i] & 0x80) == 0x80) count++;
   }
   if((by[len - 1] & 0x80) == 0x80 && (count % 2) == 1) len--;
   return new String(by, 0, len);   
  }
  catch(java.lang.ArrayIndexOutOfBoundsException e)
  {
   System.out.println(e);
   return "";
  }
 }

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/02   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
글 보관함