Java Random String randomCharacter(String availableValues)

Here you can find the source of randomCharacter(String availableValues)

Description

returns one random character from specified availableValues string

License

Open Source License

Parameter

Parameter Description
availableValues a parameter

Return

character

Declaration

public static String randomCharacter(String availableValues) 

Method Source Code

//package com.java2s;
/*/* www .  j a v  a 2s  .  c o  m*/
 *  soapUI, copyright (C) 2004-2011 eviware.com 
 *
 *  soapUI is free software; you can redistribute it and/or modify it under the 
 *  terms of version 2.1 of the GNU Lesser General Public License as published by 
 *  the Free Software Foundation.
 *
 *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
 *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 *  See the GNU Lesser General Public License for more details at gnu.org.
 */

public class Main {
    /**
     * returns one random character from specified availableValues string
     * 
     * @param availableValues
     * @return character
     */
    public static String randomCharacter(String availableValues) {
        int position = (int) (Math.random() * availableValues.length());
        return availableValues.substring(position, position + 1);
    }
}

Related

  1. getRandomStringOfLetters(int length)
  2. getString(int length)
  3. getString(int length)
  4. getString(int length)
  5. getString(int n, int arg[])
  6. randomFileString()
  7. randomFixedByteLengthUnicodeString(Random r, int length)
  8. randomFixedLengthUnicodeString(Random random, char[] chars, int offset, int length)
  9. randomize(String[] orderedList)