org.marre.util
Class StringUtil

java.lang.Object
  extended byorg.marre.util.StringUtil

public final class StringUtil
extends java.lang.Object

Various functions to encode and decode strings.

Author:
Markus Eriksson

Method Summary
static java.lang.String bytesToHexString(byte[] theData)
          Converts a byte array to a string with hex values.
static java.lang.String byteToHexString(byte theByte)
          Converts a byte to a string with hex values.
static int findString(java.lang.String[] stringTable, java.lang.String text)
           
static byte[] hexStringToBytes(java.lang.String theHexString)
          Converts a string of hex characters to a byte array.
static java.lang.String intToString(int value, int nChars)
          Method intToString.
static java.lang.String randString(int length)
          Generates a random string of the given length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findString

public static int findString(java.lang.String[] stringTable,
                             java.lang.String text)
Parameters:
stringTable -
text -
Returns:

bytesToHexString

public static java.lang.String bytesToHexString(byte[] theData)
Converts a byte array to a string with hex values.

Parameters:
theData - Data to convert
Returns:
the encoded string

byteToHexString

public static java.lang.String byteToHexString(byte theByte)
Converts a byte to a string with hex values.

Parameters:
theByte - Byte to convert
Returns:
the encoded string

hexStringToBytes

public static byte[] hexStringToBytes(java.lang.String theHexString)
Converts a string of hex characters to a byte array.

Parameters:
theHexString - The hex string to read
Returns:
the resulting byte array

intToString

public static java.lang.String intToString(int value,
                                           int nChars)
Method intToString. Converst an integer to nChars characters

Parameters:
value - Integer value
nChars - Number of chars to represent the "value"
Returns:
String The string representing "value"

randString

public static java.lang.String randString(int length)
Generates a random string of the given length. "abcdefghijklmnopqrstuvwxyz1234567890"

Parameters:
length -
Returns:
A random string


Copyright © 2002-2005 Markus Eriksson. All Rights Reserved.