Yet Another Random String Generator

Another way of generating random string

With my java-utils framework, you can generate a random string very easily. You can generate a random string of your own length, generate random alphabets lower/upper or both.


// import the package for the class gowtham.gutha.util.RandomString
import gowtham.gutha.util.*;
class rs
public static void main(String args[])

// Create RandomString object
RandomString r=new RandomString();

// Get a random string containing 10 lower case alphabets
System.out.println("Lower: "+r.lowerAlphabets(10));

// Get a random string containing 10 upper case alphabets
System.out.println("Upper: "+r.upperAlphabets(10));

// Get a random string containing 10 lower (and/or) upper alphabets
System.out.println("Any alphabet: "+r.randomAlphabets(10));

// Generate random string of any 10 characters
System.out.println("Any character: "+r.randomChars(10));



Lower: suoaklskmq
Any alphabet: uunKthBqxW
Any character:  í?GK¼§???

Resources: Download java-utils.jar and include it in classpath.

Also see my previous post Generating Random String in Java from First & Last names

Also see Generating Random Numbers in Java

Posted by at on

Tags: String Handling,