Java ID Value Create generateUniqueString(int maxLength)

Here you can find the source of generateUniqueString(int maxLength)

Description

generate Unique String

License

Open Source License

Declaration

public static String generateUniqueString(int maxLength) 

Method Source Code

//package com.java2s;
/**//www  . java2 s  .  co  m
 * DataUtils.java
 *
 * Copyright (c) 1998 - 2008 BusinessTechnology, Ltd. All rights reserved
 *
 * This program is the proprietary and confidential information of BusinessTechnology, Ltd. and may
 * be used and disclosed only as authorized in a license agreement authorizing and controlling such
 * use and disclosure
 *
 * Millennium Business Suite Anywhere System.
 */

import java.util.Random;

public class Main {

    public static String generateUniqueString(int maxLength) {
        String str = String.valueOf(Math.abs(new Random().nextLong()));
        if (maxLength < str.length())
            return str.substring(0, maxLength);
        else
            return str;
    }
}

Related

  1. generateSalt()
  2. generateUniqueId()
  3. generateUniqueId()
  4. generateUniqueIdentity()
  5. generateUniqueName(String kind)
  6. toId(String id)
  7. toId(String name)
  8. toId(String text)
  9. toIdableName(String xpath)