Generate Random String

800 views
Skip to first unread message

spierce7

unread,
Aug 17, 2010, 12:05:16 AM8/17/10
to Google Web Toolkit
What would be the best way to generate a random string in GWT with no
slashes (/ or \), preferably just capitol letters and numbers. How
would I do this? I'm surprised I can't turn up any information in
searches. I'm looking to do this Server Side, meaning in java, rather
than javascript. Thanks!

~Scott

Jim Douglas

unread,
Aug 17, 2010, 12:49:01 AM8/17/10
to Google Web Toolkit
I did this google search:

http://www.google.com/search?q=java+generate+random+alphanumeric+string

That returns more suggestions that you could possibly need; take your
pick. The first link returned from that search has several
suggestions:

http://stackoverflow.com/questions/41107/how-to-generate-a-random-alpha-numeric-string-in-java

spierce7

unread,
Aug 17, 2010, 9:35:38 AM8/17/10
to Google Web Toolkit
AH! I didn't think to search just java! Stupid me. Thanks so much.

On Aug 17, 12:49 am, Jim Douglas <jdoug...@basis.com> wrote:
> I did this google search:
>
> http://www.google.com/search?q=java+generate+random+alphanumeric+string
>
> That returns more suggestions that you could possibly need; take your
> pick.  The first link returned from that search has several
> suggestions:
>
> http://stackoverflow.com/questions/41107/how-to-generate-a-random-alp...

lineman78

unread,
Aug 17, 2010, 1:01:38 PM8/17/10
to Google Web Toolkit
In Java you could also use the UUID class, but doubt its ported into
GWT. Also, simply using the long value of time is also effective
assuming that there is no chance of ever generating 2 at the exact
same time(i.e. result of a user action): Long.toString(new
Date().getTime());
Reply all
Reply to author
Forward
0 new messages