net.sourceforge.jcetaglib.tools
Class FileTools

java.lang.Object
  extended bynet.sourceforge.jcetaglib.tools.FileTools

public class FileTools
extends java.lang.Object

Tools to handle some common file operations.

Version:
$Id: FileTools.java,v 1.4 2004/04/15 07:28:36 hamgert Exp $

Constructor Summary
FileTools()
          Creates new FileTools
 
Method Summary
static byte[] getBytesFromPEM(byte[] inbuf, java.lang.String beginKey, java.lang.String endKey)
          Reads binary bytes from a PEM-file.
static byte[] readFiletoBuffer(java.lang.String file)
          Helpfunction to read a file to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTools

public FileTools()
Creates new FileTools

Method Detail

getBytesFromPEM

public static byte[] getBytesFromPEM(byte[] inbuf,
                                     java.lang.String beginKey,
                                     java.lang.String endKey)
                              throws java.io.IOException
Reads binary bytes from a PEM-file. The PEM-file may contain other stuff, the first item between beginKey and endKey is read.

Example:

-----BEGIN CERTIFICATE REQUEST-----

-----END CERTIFICATE REQUEST-----

Parameters:
inbuf - input buffer containing PEM-formatted stuff.
Returns:
byte[] containing binary Base64 decoded bytes.
Throws:
java.io.IOException - if the PEM file does not contain the right keys.

readFiletoBuffer

public static byte[] readFiletoBuffer(java.lang.String file)
                               throws java.io.IOException
Helpfunction to read a file to a byte array.

Parameters:
file - filename of file.
Returns:
byte[] containing the contents of the file.
Throws:
java.io.IOException - if the file does not exist or cannot be read.