Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { public static boolean isValidBillTitleLength(String str) { if (!isValidString(str)) return false; boolean res = false; try { byte[] bytes = str.getBytes("GBK"); if (bytes.length <= 32) res = true; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return res; } public static boolean isValidString(String str) { return str != null && str.length() != 0; } }