01: /**
02: * $Id: RandomNumber.java,v 1.6 2005/11/30 11:26:35 ss150821 Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.netfile.servlet.java1;
14:
15: import java.util.*;
16: import com.sun.portal.log.common.PortalLogger;
17:
18: public class RandomNumber {
19:
20: //-----------------------------------------
21: // A method to generate random numbers.
22: //-----------------------------------------
23:
24: public String randomNumbers() {
25:
26: Random generator = new Random();
27: generator.setSeed(System.currentTimeMillis());
28: int rand = generator.nextInt();
29:
30: // This is to generate unique number. (appr) rand modulus of 2 to the power 16.
31: int num = Math.abs(rand % 65000) * 3;
32: String randnom = Integer.toString(num + 1);
33:
34: return randnom;
35: }
36: }
|