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.
-
Util()
-
-
Base64Decode(byte[])
- Decodes a Base64 encoded byte array.
-
Base64Encode(byte[])
- Encodes a binary byte array into Base64.
-
loadClass(String, boolean)
- Tries to dynamically load a class.
-
readFile(String)
- Read a file into a byte array.
-
saveToFile(byte[], String)
- Save a byte array to a file.
-
toString(byte)
- Converts a byte into a hex string.
-
toString(byte[])
- Converts a byte array to a hex string of the format: 01:23:34:56...
-
toString(byte[], int, int)
- Converts a byte array to a hex string of the format: 01:23:34:56...
Util
public Util()
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
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
saveToFile
public static void saveToFile(byte array[],
String fileName) throws IOException
- Save a byte array to a file.
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
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
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
Base64Encode
public static byte[] Base64Encode(byte in[])
- Encodes a binary byte array into Base64.
- Parameters:
- in - the binary data
- Returns:
- the encoded data
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