5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【commons-lang3】 RandomStringUtils のよく利用する(しそう)メソッド

Posted at

メモ


import org.apache.commons.lang3.RandomStringUtils;

public class Main {

	public static void main(String[] args) {

		// 10文字のランダムな文字列生成
		System.out.println(RandomStringUtils.random(10));
		// アスキー文字で 10文字のランダムな文字列生成
		System.out.println(RandomStringUtils.randomAscii(10));
		// 英字で 10文字のランダムな文字列生成
		System.out.println(RandomStringUtils.randomAlphabetic(10));
		// 英数字で 10文字のランダムな文字列生成
		System.out.println(RandomStringUtils.randomAlphanumeric(10));
		// 数字で 10文字のランダムな文字列生成
		System.out.println(RandomStringUtils.randomNumeric(10));
		// 任意の文字で 10文字のランダムな文字列生成
		System.out.println(RandomStringUtils.random(10, "01234567".toCharArray()));
	}
}
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?