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

br.com.jhonsapp.bootstrap.object.util.CodeGenerator Maven / Gradle / Ivy

The newest version!
package br.com.jhonsapp.bootstrap.object.util;

import java.util.Random;

/**
 * This class generates a String code based on a random characters quantity.
 * 
 * @author Jhonathan Camacho
 *
 */
public class CodeGenerator {

	/**
	 * Generates a code based on a characters quantity.
	 * 
	 * @param quantity
	 *            the number of characters of the token.
	 * @return the code generated.
	 */
	public static String generateCode(int quantity) {
		String number = "";

		Random generator = new Random();

		for (int i = 0; i < quantity; i++) {
			number = number + String.valueOf(generator.nextInt(10));
		}
		return number;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy