All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liberologico.cloudesire.common.RandomStringUtils Maven / Gradle / Ivy

package com.liberologico.cloudesire.common;

import java.util.UUID;

public class RandomStringUtils
{
    public static String randomToken( int maxLength )
    {
        if ( maxLength < 1 ) throw new IllegalArgumentException( "should be at least 1" );
        StringBuilder stringBuilder = new StringBuilder();
        do
        {
            stringBuilder.append( UUID.randomUUID().toString().replace( "-", "" ) );
        } while ( stringBuilder.length() < maxLength );
        return stringBuilder.substring( 0, maxLength );
    }

    private RandomStringUtils()
    {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy