java随机生成汉字
public static void main(String[] args) { String str = null; int hs, ls; Random random = new Random(); hs = (176 + Math.abs(random.nextInt(39))); ls = (161 + Math.abs(random.nextInt(93))); byte[] b = new byte[2]; b[0] = (new Integer(hs).byteValue()); b[1] = (new Integer(ls).byteValue()); try { str = new String(b, "GBk"); //转成中文 System.out.println(str);; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
看完打开支付宝扫一扫领个红包吧!