public static int getLength(String str) { int ret = 0; byte[] bytes; try { // MS932エンコード bytes = str.getBytes("MS932"); if (bytes != null) ret = bytes.length; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ret; }