Created
February 16, 2012 11:41
-
-
Save froop/1844275 to your computer and use it in GitHub Desktop.
[Java] ランダム文字列生成(仮パスワード用)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang3.RandomStringUtils; | |
@Test public void testRandomStringUtils() { | |
String random1 = RandomStringUtils.randomAlphanumeric(10); | |
String random2 = RandomStringUtils.randomAlphanumeric(10); | |
assertTrue(random1, random1.matches("[a-zA-Z0-9]{10}")); | |
assertTrue(random2, random2.matches("[a-zA-Z0-9]{10}")); | |
assertFalse(random1.equals(random2)); | |
System.out.println(random1); | |
System.out.println(random2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment