仅采用GB2312 一级字库,即 B0A1~D7FE 共计 3760 个字符
来源:互联网 发布:知敬畏守规矩事例 编辑:程序博客网 时间:2024/06/05 06:35
- public class Test01 {
-
- public static void main(String[] args) {
- long t0, t1;
- t0 = System.currentTimeMillis();
- String str = getRandomString(2000000);
- t1 = System.currentTimeMillis();
- System.out.println(t1 - t0);
- System.out.println(str.length());
- }
-
- private static String getRandomString(int length) {
- if(length < 1) {
- return "";
- }
- byte[] bys = new byte[length * 2];
- Random ran = new Random();
- for(int i = 0; i < length; i++) {
- bys[2 * i] = (byte)(ran.nextInt(40) + 176);
- bys[2 * i + 1] = (byte)(ran.nextInt(94) + 161);
- }
- return new String(bys);
- }
- }