The randomstringutils of Commons

Source: Internet
Author: User
Tags alphabetic character alphanumeric characters
Import java.util.random;    Import org.apache.commons.lang3.randomstringutils;    public class Randomstringutilsdemo {            private static final Random Random = new Random ();            private static final int count = 4;             private static final int start = 0;         & nbsp;  private static final int end = 3;            private static final String str = "abcd1234";            private static final char[] chars = {' A ', ' B ', ' 1 ', ' 2 ', ' C ', ' d ', ' E ',              ' f ', ' 3 '};& nbsp       public static void Main (string[] args) {         /* & Nbsp;        * 1. Create a random string with a length of count.          * In the Chinese environment is garbled.          */          System.out.println ("random1:" + randomstringutils.random (count));            /*          * 2. Create a random string of length count from the chars of the specified character array.          */          System.out.println ("random2:" + randomstringutils.random (count, chars));            /*          * 3. Create a random string of length count that is combined from the specified string str extract character          */          System.out.println ("RANDOM3:" + randomstringutils.random (count, str));            /*          * 4. Create a random string of length count based on letters and numbers. The value returned by letters for true contains the alphanumeric characters          * Numbers The value returned for true contains numeric characters           */          System.out.println (" RANDOM4: "                  + Randomstringutils.random (count, True, true);           /*           *

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.