aspose file tools*
The moose likes Beginning Java and the fly likes how to generate unique number? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to generate unique number?" Watch "how to generate unique number?" New topic
Author

how to generate unique number?

xiaoyi hou
Greenhorn

Joined: May 20, 2001
Posts: 21
a server support muliple client connections, the clients create some objects and store them on the server, these objects should be each assigned a unique number. my question is how to generate them, by who, server or client?
thank you
X HOU
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
I would think that the server should assign the unique numbers since it is the central repository for the objects.

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
xiaoyi hou
Greenhorn

Joined: May 20, 2001
Posts: 21
Originally posted by Marilyn deQueiroz:
I would think that the server should assign the unique numbers since it is the central repository for the objects.

but how?
Matthew Margolis
Ranch Hand

Joined: Sep 29, 2001
Posts: 32
If you are saving this info to a file or files you could generate a random number or better yet to insure no duplicates use the time and date as the filename. If you have the user creating multiple files at one time then you could use the date + time + a number representing that files contents (eg 11180105309 where 11 18 01 is the date 05 30 is the time and 9 is the number you are using to signify what particular object you are representing in that file.
[This message has been edited by Matthew Margolis (edited November 19, 2001).]
 
 
subject: how to generate unique number?