Java automatically generates random Chinese classes

Source: Internet
Author: User


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). byteValue ();

B [1] = (new Integer (lowPos). byteValue ();

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 getaskname (int betweenZeroAndThirty ){

Switch (betweenZeroAndThirty ){

Case 0:

Return "New Central Hotel ";

Case 1:

Return "grand ";

Case 2:

Return "East Asia Hotel ";

Case 3:

Return "Imperial Palace Hotel ";

Case 4:

Return "God of Wealth Hotel ";

Case 5:

Return "Macao fuhua Yuehai Hotel ";

Case 6:

Return "golden crown China Hotel ";

Case 7:

Return "Golden Dragon Hotel ";

Case 8:

Return "Emperor Entertainment Hotel ";

Case 9:

Return "golden Capital Hotel ";

Case 10:

Return "Jun Yi Hotel ";

Case 11:

Return "Dong Wangyang Hotel ";

Case 12:

Return "Holiday hotels ";

Case 13:

Return "Holiday Inn Macau ";

Case 14:

Return "Holiday Inn Macau ";

Case 15:

Return "kangtai Hotel ";

Case 16:

Return "regal Macao Hotel ";

Case 17:

Return "Royal kingburg Hotel ";

Case 18:

Return "Global Hotel ";

Case 19:

Return "Les Hotel ";

Case 20:

Return "Huili Hotel ";

Case 21:

Return "Golden Mile Hotel ";

Case 22:

Return "Landmark Hotel ";

Case 23:

Return "Lisboa Hotel ";

Case 24:

Return "Yingjing Hotel ";

Case 25:

Return "hotel ";

Case 26:

Return "Mandarin ";

Case 27:

Return "Mandarin Oriental Hotel ";

Case 28:

Return "weijing Hotel ";

Case 29:

Return "New Century Hotel ";

Default:

Return "Li Ao Hotel ";

}

}

 

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 ";

Case 9:

Return "Poland ";

Case 10:

Return "Iceland ";

Default:

Return "China ";

}

}

 

Public static String getCustomerName (int betweenZeroAndTen ){

Switch (betweenZeroAndTen ){

Case 0:

Return "Brishen ";

Case 1:

Return "Andy ";

Case 2:

Return "Tony ";

Case 3:

Return "Wayne ";

Case 4:

Return "Jhon ";

Case 5:

Return "PaPa ";

Case 6:

Return "Juyne ";

Case 7:

Return "Marry ";

Case 8:

Return "Harmony ";

Case 9:

Return "Brandon ";

Case 10:

Return "Carlyle ";

Default:

Return"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.