Java Random String randomString()

Here you can find the source of randomString()

Description

Generate a random string, of a specified length.

License

Open Source License

Return

A random string.

Declaration

protected static String randomString() 

Method Source Code

//package com.java2s;
/**//  w w  w  .  jav a  2s .c  om
 * The Heaton Research Spider Copyright 2007 by Heaton
 * Research, Inc.
 * 
 * HTTP Programming Recipes for Java ISBN: 0-9773206-6-9
 * http://www.heatonresearch.com/articles/series/16/
 * 
 * FormUtility: This class is used to construct responses to
 * HTML forms. The class supports both standard HTML forms,
 * as well as multipart forms.
 * 
 * This class is released under the:
 * GNU Lesser General Public License (LGPL)
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * @author Jeff Heaton
 * @version 1.1
 */

import java.util.*;

public class Main {
    private static Random random = new Random();

    /**
     * Generate a random string, of a specified length. This
     * is used to generate the multipart boundary.
     * 
     * @return A random string.
     */
    protected static String randomString() {
        return Long.toString(random.nextLong(), 36);
    }
}

Related

  1. randomizeMap(Map map)
  2. randomlyRecaseCodePoints(Random random, String str)
  3. randomNumberString(int in)
  4. randomRealisticUnicodeString(Random r)
  5. randomString()
  6. randomString(final int length)
  7. randomString(int len)
  8. randomString(int length)
  9. randomString(int length)