【java学习】RandomStringUtils

  // 产生5位长度的随机字符串,中文环境下是乱码  
        String r = RandomStringUtils.random(5);  
        System.out.println(r);  
  
        // 使用指定的字符生成5位长度的随机字符串  
        r = RandomStringUtils.random(5, new char[] { 'a', 'b', 'c', 'd', 'e',  
                'f', '1', '2', '3' });  
        System.out.println(r);  
  
        // 生成指定长度的字母和数字的随机组合字符串  
        r = RandomStringUtils.randomAlphanumeric(5);  
        System.out.println(r);  
  
        // 生成随机数字字符串  
        r = RandomStringUtils.randomNumeric(5);  
        System.out.println(r);  
  
        // 生成随机[a-z]字符串,包含大小写  
        r = RandomStringUtils.randomAlphabetic(5);  
        System.out.println(r);  
  
        // 生成从ASCII 32到126组成的随机字符串  
        r = RandomStringUtils.randomAscii(4);  
        System.out.println(r);  
  • Constructor and Description
    RandomStringUtils()

    RandomStringUtils instances should NOT be constructed in standard programming.

  • Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and TypeMethod and Description
    static Stringrandom(int count)

    Creates a random string whose length is the number of characters specified.

    static Stringrandom(int count, boolean letters, boolean numbers)

    Creates a random string whose length is the number of characters specified.

    static Stringrandom(int count, char... chars)

    Creates a random string whose length is the number of characters specified.

    static Stringrandom(int count, int start, int end, boolean letters, boolean numbers)

    Creates a random string whose length is the number of characters specified.

    static Stringrandom(int count, int start, int end, boolean letters, boolean numbers, char... chars)

    Creates a random string based on a variety of options, using default source of randomness.

    static Stringrandom(int count, int start, int end, boolean letters, boolean numbers, char[] chars, Random random)

    Creates a random string based on a variety of options, using supplied source of randomness.

    static Stringrandom(int count, String chars)

    Creates a random string whose length is the number of characters specified.

    static StringrandomAlphabetic(int count)

    Creates a random string whose length is the number of characters specified.

    static StringrandomAlphabetic(int minLengthInclusive, int maxLengthExclusive)

    Creates a random string whose length is between the inclusive minimum and the exclusive maximum.

    static StringrandomAlphanumeric(int count)

    Creates a random string whose length is the number of characters specified.

    static StringrandomAlphanumeric(int minLengthInclusive, int maxLengthExclusive)

    Creates a random string whose length is between the inclusive minimum and the exclusive maximum.

    static StringrandomAscii(int count)

    Creates a random string whose length is the number of characters specified.

    static StringrandomAscii(int minLengthInclusive, int maxLengthExclusive)

    Creates a random string whose length is between the inclusive minimum and the exclusive maximum.

    static StringrandomGraph(int count)

    Creates a random string whose length is the number of characters specified.

    static StringrandomGraph(int minLengthInclusive, int maxLengthExclusive)

    Creates a random string whose length is between the inclusive minimum and the exclusive maximum.

    static StringrandomNumeric(int count)

    Creates a random string whose length is the number of characters specified.

    static StringrandomNumeric(int minLengthInclusive, int maxLengthExclusive)

    Creates a random string whose length is between the inclusive minimum and the exclusive maximum.

    static StringrandomPrint(int count)

    Creates a random string whose length is the number of characters specified.

    static StringrandomPrint(int minLengthInclusive, int maxLengthExclusive)

    Creates a random string whose length is between the inclusive minimum and the exclusive maximum.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

路途…

点滴记录

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值