com.multisoftgroup.jerry.webchat.util
Class StringUtils

java.lang.Object
  extended by com.multisoftgroup.jerry.webchat.util.StringUtils

public class StringUtils
extends Object

A collection of utility methods for String objects.


Method Summary
static byte[] decodeBase64(String data)
          Decodes a base64 String.
static String encodeBase64(byte[] data)
          Encodes a byte array into a base64 String.
static String encodeBase64(String data)
          Encodes a String as a base64 String.
static String randomString(int length)
          Returns a random String of numbers and letters (lower and upper case) of the specified length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeBase64

public static String encodeBase64(String data)
Encodes a String as a base64 String.

Parameters:
data - a String to encode.
Returns:
a base64 encoded String.

encodeBase64

public static String encodeBase64(byte[] data)
Encodes a byte array into a base64 String.

Parameters:
data - a byte array to encode.
Returns:
a base64 encode String.

decodeBase64

public static byte[] decodeBase64(String data)
Decodes a base64 String.

Parameters:
data - a base64 encoded String to decode.
Returns:
the decoded String.

randomString

public static final String randomString(int length)
Returns a random String of numbers and letters (lower and upper case) of the specified length. The method uses the Random class that is built-in to Java which is suitable for low to medium grade security uses. This means that the output is only pseudo random, i.e., each number is mathematically generated so is not truly random.

The specified length must be at least one. If not, the method will return null.

Parameters:
length - the desired length of the random String to return.
Returns:
a random String of numbers and letters of the specified length.