Java ID Value Create generateUniqueId()

Here you can find the source of generateUniqueId()

Description

generate Unique Id

License

Apache License

Declaration

public static String generateUniqueId() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Locale;
import java.util.Random;

public class Main {
    private static String UNIQUEID_LETTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private static int UNIQUEID_DEFAULTSIZE = 6;

    public static String generateUniqueId() {
        StringBuilder sb = new StringBuilder(UNIQUEID_DEFAULTSIZE);
        Random random = new Random();
        for (int i = 0; i < UNIQUEID_DEFAULTSIZE; i++) {
            sb.append(UNIQUEID_LETTERS.charAt(random.nextInt(UNIQUEID_LETTERS.length())));
        }//from  w  w  w. java2  s  .c o m
        return sb.toString().toLowerCase(Locale.US);
    }
}

Related

  1. generateID(String origin)
  2. generateId(String salt)
  3. generateSalt()
  4. generateSalt()
  5. generateSalt()
  6. generateUniqueId()
  7. generateUniqueIdentity()
  8. generateUniqueName(String kind)
  9. generateUniqueString(int maxLength)