java×Ô¶¯Éú³ÉËæ»úÖÐÎÄÀà(Ò»)

2014-11-24 01:08:53 ¡¤ ×÷Õß: ¡¤ ä¯ÀÀ: 2


import java.io.UnsupportedEncodingException;

import java.util.Date;

import java.util.Random;

public class ChineseUtils {

private static Random random = null;

private static Random getRandomInstance() {

if (random == null) {

random = new Random(new Date().getTime());

}

return random;

}

public static String getChinese() {

String str = null;

int highPos, lowPos;

Random random = getRandomInstance();

highPos = (176 + Math.abs(random.nextInt(39)));

lowPos = 161 + Math.abs(random.nextInt(93));

byte[] b = new byte[2];

b[0] = (new Integer(highPos)).byteva lue();

b[1] = (new Integer(lowPos)).byteva lue();

try {

str = new String(b, "GB2312");

} catch (UnsupportedEncodingException e) {

e.printStackTrace();

}

return str;

}

public static String getFixedLengthChinese(int length) {

String str = "";

for (int i = length; i > 0; i--) {

str = str + ChineseUtils.getChinese();

}

return str;

}

public static String getRandomLengthChiness(int start, int end) {

String str = "";

int length = new Random().nextInt(end + 1);

if (length < start) {

str = getRandomLengthChiness(start, end);

} else {

for (int i = 0; i < length; i++) {

str = str + getChinese();

}

}

return str;

}

public static String getUserName(int betweenZeroAndSix) {

switch (betweenZeroAndSix) {

case 0:

return "Baul";

case 1:

return "Ebony";

case 2:

return "Tony";

case 3:

return "Charles";

case 4:

return "Pebbles";

case 5:

return "Queen";

default:

return "Kismet";

}

}

public static String getSupplierName(int betweenZeroAndSix) {

switch (betweenZeroAndSix) {

case 0:

return "Ulrika";

case 1:

return "Unity";

case 2:

return "Zelene";

case 3:

return "Shelby";

case 4:

return "Coleman";

case 5:

return "Fielding";

default:

return "Sabrina";

}

}

public static String getHotelName(int betweenZeroAndThirty) {

switch (betweenZeroAndThirty) {

case 0:

return "ÐÂÖÐÑë¾Æµê";

case 1:

return "¸ñÀ¼";

case 2:

return "¶«ÑǾƵê";

case 3:

return "µÛ婾Ƶê";

case 4:

return "²ÆÉñ¾Æµê";

case 5:

return "°Äß»»ªÔÁº£¾Æµê";

case 6:

return "½ð»Ê¹ÚÖйú´ó¾Æµê";

case 7:

return "½ðÁú¾Æµê";

case 8:

return "Ó¢»ÊÓéÀ־Ƶê";

case 9:

return "½ð¶¼¾Æµê";

case 10:

return "¾ýâù¾Æµê";

case 11:

return "¶«ÍûÑ󾯵ê";

case 12:

return "¼ÙÆÚ¾Æµê";

case 13:

return "°ÄÃżÙÈվƵê";

case 14:

return "°ÄÃżÙÈվƵê";

case 15:

return "¿µÌ©¾Æµê";

case 16:

return "°Äß»ºÀ¾Æµê";

case 17:

return "»Ê¼Ò½ð±¤¾Æµê";

case 18:

return "»·Çò¾Æµê";

case 19:

return "À³Ë¹¾Æµê";

case 20:

return "»ØÁ¦¾Æµê";

case 21:

return "½ðÓò¾Æµê";

case 22:

return "Öõع㳡¾Æµê";

case 23:

return "ÆÏ¾©¾Æµê";

case 24:

return "Ó¢¾©¾Æµê";

case 25:

return "ÍòÊ·¢¾Æµê";

case 26:

return "ÎÄ»ª";

case 27:

return "ÎÄ»ª¶«·½¾Æµê";

case 28:

return "ά¾°¾Æµê";

case 29:

return "ÐÂÊÀ¼Í¾Æµê";

default:

return "Àû°Ä¾Æµê";

}

}

public static String getNationality(int betweenZeroAndTen) {

switch (betweenZeroAndTen) {

case 0:

return "Egypt";

case 1:

return "Azerbaijan";

case 2:

return "Ireland";

case 3:

return "Estonia";

case 4:

return "Austria";

case 5:

return "Anguilla";

case 6:

return "Macau";

case 7:

return "Barbados";

case 8:

return "Papua New Guinea";