public String getRandomText ( final int minLength , final int maxLength ) { validateMinMaxParams ( minLength , maxLength ) ; StringBuilder sb = new StringBuilder ( maxLength ) ; int length = minLength ; if ( maxLength != minLength ) { length = length + random . nextInt ( maxLength - minLength ) ; } while ( length > 0 ) { if ( sb . length ( ) != 0 ) { sb . append ( " " ) ; length -- ; } final double desiredWordLengthNormalDistributed = 1.0 + Math . abs ( random . nextGaussian ( ) ) * 6 ; int usedWordLength = ( int ) ( Math . min ( length , desiredWordLengthNormalDistributed ) ) ; String word = getRandomWord ( usedWordLength ) ; sb . append ( word ) ; length = length - word . length ( ) ; } return sb . toString ( ) ; }
Returns random text made up of english words