标签:span class pre div rgs break oid stat else
public class ByteSub { public static void subString(String str, int a) { int bytes = 0; String result = ""; for (int x = 0; x < str.length(); x++) { byte[] b = (str.charAt(x) + "").getBytes(); bytes += b.length; if (bytes > a) { break; } else { result += str.charAt(x); } } System.out.println(result); } public static void main(String[] args) { subString("中国abcd", 3); } }
标签:span class pre div rgs break oid stat else
原文地址:http://www.cnblogs.com/LZL-student/p/6260022.html