Here you can find the source of generateRandomString(int wordsLength, String separator)
Parameter | Description |
---|---|
wordsLength | a parameter |
public static String generateRandomString(int wordsLength, String separator)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static String[] words = new String[] { "cogitation", "unwilful", "intendment", "flexibleness", "intervertebrally", "magi", "phalanx", "pipsqueak", "bosnian", "martinmas", "vimana", "agitational", "hyperorthognathous", "hierarchize", "cheshunt", "trachea", "consternate", "deep", "calcimined", "sublunated", "sorer", "interlaminar", "polemicist", "overassertive", "endolymph", "dichloride", "simultaneously", "prerejoicing", "degradedness", "hexameron", "consecratedness", "nondisciplining", "bimorph", "planck", "somewise", "milfoil", "postprandially", "isolate", "pseudoerotic", "fishiness", "benefiter", "kola", "socialist", "frenchify", "unglorifying", "innovating", "sotol", "downcastly", "wkly", "unabolished", "cogitation", "unwilful", "intendment", "flexibleness", "intervertebrally", "magi", "phalanx", "pipsqueak", "bosnian", "martinmas", "vimana", "agitational", "hyperorthognathous", "hierarchize", "cheshunt", "trachea", "consternate", "deep", "calcimined", "sublunated", "sorer", "interlaminar", "polemicist", "overassertive", "endolymph", "dichloride", "simultaneously", "prerejoicing", "degradedness", "hexameron", "consecratedness", "nondisciplining", "bimorph", "planck", "somewise", "milfoil", "postprandially", "isolate", "pseudoerotic", "fishiness", "benefiter", "kola", "socialist", "frenchify", "unglorifying", "innovating", "sotol", "downcastly", "wkly", "unabolished" }; /**/* w ww .jav a 2 s . c o m*/ * Generates a string of random words with the supplied separator * @param wordsLength * @return */ public static String generateRandomString(int wordsLength, String separator) { Random rand = new Random(); String sb = ""; for (int i = 0; i < wordsLength; i++) { int randomWord = rand.nextInt(words.length); if (i != 0) { sb += separator; } sb += words[randomWord]; } return sb; } }