Introduction and use of JAVA to generate Universal Unique Identifier (UUID)

01. Introduction of UUID

UUID is an acronym for Universally Unique Identifier, a standard for software construction and a part of the Open Software Foundation in the field of distributed computing environments. The purpose is to allow all elements in the distributed system to have unique identification information, without the need to specify identification information through the central control terminal. This way, everyone can create UUIDs that don't conflict with everyone else. In such a case, there is no need to consider the problem of duplication of names when the database is created. Currently the most widely used UUID is Microsoft's Globally Unique Identifier (GUID), while other important applications include Linux ext2/ext3 file systems, LUKS encrypted partitions, GNOME, KDE, Mac OS X, and more. Alternatively we can find the implementation in the UUID library in the e2fsprogs package. Details Baidu ( https://baike.baidu.com/item/UUID ). UUID is also widely used in website development and primary keys in databases. For the use of activation codes, the primary keys of tables are very practical.

02. Simple demo

public static void main(String[] args) {
        //原始的   UUID码
        UUID uuid=UUID.randomUUID();
        String uuidStr = uuid.toString();
        String uuidRep=uuidStr.replaceAll("-", "");
        System.out.println("原始UUID:"+uuid);
        System.out.println("转成字符后的UUID:"+uuidStr);
        System.out.println("去掉-的UUID字符串:"+uuidRep);
    }

result:
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326052517&siteId=291194637