public static String number ( int numberOfDigits ) { if ( numberOfDigits < 1 ) { return "" ; } StringBuffer sb = new StringBuffer ( randomIntBetweenTwoNumbers ( 1 , 9 ) + "" ) ; if ( numberOfDigits == 1 ) { return sb . toString ( ) ; } char [ ] chars = "123456789" . toCharArray ( ) ; String secondHalf = RandomStringUtils . random ( numberOfDigits - 1 , 0 , 8 , false , false , chars ) ; return sb . append ( secondHalf ) . toString ( ) ; }
random number string without 0 being possible as the first digit