commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@joda.org>
Subject Fw: RandomStringUtils Bug
Date Mon, 12 May 2003 17:34:35 GMT

----- Original Message ----- 
From: <rs@haenchen.softwarezentrum.de>
To: <scolebourne@joda.org>
Sent: Monday, May 12, 2003 3:53 PM
Subject: RandomStringUtils Bug


> Hi Stephen,
> 
> may I suggest to change the Code to the method random:
> 
> public static String random(int count, char[] set) 
> {
>   return random(count, 0, set.length, false, false, set);
> }
> 
> The change is not to subtract 1 from set.length. It happens to me
> that, based on your implementation, the highest char of the array never
> got chosen.
> 
> E.g.
> 
> String s = RandomStringUtils.random(25,"abc123");
> System.out.println(s);
> 
> used to produce
> 
> acaa2bbcb2211a2a2b22a21ab
> 2aac2cc2211b22babbbcc12ab
> bc11c1aba21caabc1bcbaa1ac
> 
> You may notice that there is no character '3' in it.
> 
> After my change I get
> 
> 11222233c2abcbacbbc1ba2cb
> ba1aaa2c2aa1112bb331c1332
> 32aaa333123312b2baaacacb1
> 
> 
> Hope this is for use for you.
> 
> 
> Roman
> 
> 
> -- 
> ________________________________________________________________________
> Roman Seibold, Dipl.-Inform.
> Haenchen & Partner, Beratungsgesellschaft fuer Wirtschaftsinformatik mbH
> Calwer Str. 1,  71034 Boeblingen, Germany
> 
> Roman.Seibold(at)haenchen.softwarezentrum.de
> http://www.haenchen.softwarezentrum.de
> Phone: +49 (0)7031 2126 100
> FAX:   +49 (0)7031 2126 199
> ________________________________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message