Java UUID Create generateGUID()

Here you can find the source of generateGUID()

Description

generate GUID

License

Apache License

Declaration

public static String generateGUID() 

Method Source Code

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

import java.util.UUID;

public class Main {

    public static String generateGUID() {
        return replaceWithBlank(UUID.randomUUID().toString(), '-');
    }/*from  w ww .j  a va2s .c o m*/

    public static String replaceWithBlank(String value, char oldChar) {
        if (null == value || value.length() == 0) {
            return value;
        }

        int len = value.length();
        int index = 0;
        char[] newValue = new char[len];
        for (int i = 0; i < len; i++) {
            char currentChar = value.charAt(i);
            if (currentChar != oldChar) {
                newValue[index++] = currentChar;
            }
        }

        return new String(newValue, 0, index);
    }
}

Related

  1. generateContentID()
  2. generateCurrentTimestampUUID()
  3. generateEmailPrefix()
  4. generateFakedDeviceTokenString()
  5. generateFileName(String path)
  6. generateGUID()
  7. generateId()
  8. generateID()
  9. generateId()