All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class iaik.utils.Util

java.lang.Object
   |
   +----iaik.utils.Util

public class Util
extends Object
This class provides some general useful methods.


Constructor Index

 o Util()

Method Index

 o Base64Decode(byte[])
Decodes a Base64 encoded byte array.
 o Base64Encode(byte[])
Encodes a binary byte array into Base64.
 o loadClass(String, boolean)
Tries to dynamically load a class.
 o readFile(String)
Read a file into a byte array.
 o saveToFile(byte[], String)
Save a byte array to a file.
 o toString(byte)
Converts a byte into a hex string.
 o toString(byte[])
Converts a byte array to a hex string of the format: 01:23:34:56...
 o toString(byte[], int, int)
Converts a byte array to a hex string of the format: 01:23:34:56...

Constructors

 o Util
 public Util()

Methods

 o loadClass
 public static boolean loadClass(String name,
                                 boolean createInstance)
Tries to dynamically load a class.

Parameters:
name - the name of the class to load (e.g. "iaik.Test")
createInstance - if true a new instance of the class is created Some implementations of the Java-VM only execute the static part of a class if a new instance is created.
Returns:
true, if the class was loaded successfully and a new instance was created if desired; false otherwise
 o readFile
 public static byte[] readFile(String fileName) throws IOException
Read a file into a byte array.

Parameters:
String - fileName the name of the file to read
Returns:
the content of the file in a byte array
Throws: IOException
if an IO error occurs
 o saveToFile
 public static void saveToFile(byte array[],
                               String fileName) throws IOException
Save a byte array to a file.

 o toString
 public static String toString(byte b)
Converts a byte into a hex string.

Parameters:
b - the byte to convert
Returns:
the byte as hex value
 o toString
 public static String toString(byte byteArray[],
                               int off,
                               int len)
Converts a byte array to a hex string of the format: 01:23:34:56...

Parameters:
byteArray - the byte array containing the data
len - how many bytes shall be written
Returns:
the string representation
 o toString
 public static String toString(byte byteArray[])
Converts a byte array to a hex string of the format: 01:23:34:56...

Parameters:
byteArray - the byte array containing the data
Returns:
the string representation
 o Base64Encode
 public static byte[] Base64Encode(byte in[])
Encodes a binary byte array into Base64.

Parameters:
in - the binary data
Returns:
the encoded data
 o Base64Decode
 public static byte[] Base64Decode(byte in[]) throws Base64Exception
Decodes a Base64 encoded byte array.

Parameters:
in - the Base64 encoded data
Returns:
the decoded data
Throws: Base64Exception
if there occurs an error while decoding

All Packages  Class Hierarchy  This Package  Previous  Next  Index