Here you can find the source of generateUniqueString(int maxLength)
public static String generateUniqueString(int maxLength)
//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; } }