All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jaxws.util.lang.RandomStringUtils Maven / Gradle / Ivy

There is a newer version: 4.2.2
Show newest version
package org.jaxws.util.lang;

import org.apache.commons.lang.math.RandomUtils;

/**
 * 
 * @author chenjianjx
 * 
 */
public class RandomStringUtils {

	public static String getRandomLetters(int length) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < length; i++) {
			sb.append(getRandomLetter());
		}
		return sb.toString();
	}

	public static char getRandomLetter() {
		return (char) (RandomUtils.nextInt(getLetterRange()) + randomlyGetLetterA());
	}

	private static int getLetterRange() {
		return 'Z' - 'A' + 1;
	}

	private static int randomlyGetLetterA() {
		return RandomUtils.nextBoolean() ? 'A' : 'a';

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy