Class Base64Encoder

java.lang.Object
org.castor.core.util.Base64Encoder

public final class Base64Encoder extends Object
Class encodes the bytes written to the OutPutStream to a Base64 encoded string. The encoded string can be retrieved by as a whole by the toString() method or splited into lines of 72 characters by the toStringArray() method.
Since:
0.9.9
Version:
$Revision: 6907 $ $Date: 2005-08-05 13:58:36 -0600 (Fri, 05 Aug 2005) $
Author:
Ralf Joachim
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a Base64Encoder.
  • Method Summary

    Modifier and Type
    Method
    Description
    static char[]
    encode(byte[] bytes)
    Encode given byte array into a encoded character array.
    char[]
    Get Base64 encoded characters as an array.
    void
    Reset Base64Encoder to its initial state.
    void
    translate(byte[] bytes)
    Translate all bytes of given array by appending each to octet buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Base64Encoder

      public Base64Encoder()
      Construct a Base64Encoder.
  • Method Details

    • encode

      public static char[] encode(byte[] bytes)
      Encode given byte array into a encoded character array.
      Parameters:
      bytes - The byte array to be encoded.
      Returns:
      Base64 encoded characters as an array.
    • reset

      public void reset()
      Reset Base64Encoder to its initial state. Take care using this method as it throws all previously written bytes away.
    • translate

      public void translate(byte[] bytes)
      Translate all bytes of given array by appending each to octet buffer. If buffer contains 3 octets its content will be encoded to 4 sextet byte values which are converted to a base64 character each. All characters are appended to a StringBuffer.
      Parameters:
      bytes - The byte array to be encoded.
    • getCharArray

      public char[] getCharArray()
      Get Base64 encoded characters as an array.
      Returns:
      Base64 encoded characters as an array.