Class Base64Encoder


  • public class Base64Encoder
    extends java.lang.Object
    The Base64Encoder is used to encode and decode base64 content. The implementation used here provides a reasonably fast memory efficient encoder for use with input and output streams. It is possible to achieve higher performance, however, ease of use and convenience are the priorities with this implementation. This can only decode complete blocks.
    Author:
    Niall Gallagher
    See Also:
    Base64OutputStream, Base64InputStream
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64Encoder()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] decode​(char[] text)
      This is used to decode the provide base64 data back in to an array of binary data.
      static byte[] decode​(char[] text, int off, int len)
      This is used to decode the provide base64 data back in to an array of binary data.
      static char[] encode​(byte[] buf)
      This method is used to encode the specified byte array of binary data in to base64 data.
      static char[] encode​(byte[] buf, int off, int len)
      This method is used to encode the specified byte array of binary data in to base64 data.
      • Methods inherited from class java.lang.Object

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

      • Base64Encoder

        public Base64Encoder()
    • Method Detail

      • encode

        public static char[] encode​(byte[] buf)
        This method is used to encode the specified byte array of binary data in to base64 data. The block is complete and must be decoded as a complete block.
        Parameters:
        buf - this is the binary data to be encoded
        Returns:
        this is the base64 encoded value of the data
      • encode

        public static char[] encode​(byte[] buf,
                                    int off,
                                    int len)
        This method is used to encode the specified byte array of binary data in to base64 data. The block is complete and must be decoded as a complete block.
        Parameters:
        buf - this is the binary data to be encoded
        off - this is the offset to read the binary data from
        len - this is the length of data to encode from the array
        Returns:
        this is the base64 encoded value of the data
      • decode

        public static byte[] decode​(char[] text)
        This is used to decode the provide base64 data back in to an array of binary data. The data provided here must be a full block of base 64 data in order to be decoded.
        Parameters:
        text - this is the base64 text to be decoded
        Returns:
        this returns the resulting byte array
      • decode

        public static byte[] decode​(char[] text,
                                    int off,
                                    int len)
        This is used to decode the provide base64 data back in to an array of binary data. The data provided here must be a full block of base 64 data in order to be decoded.
        Parameters:
        text - this is the base64 text to be decoded
        off - this is the offset to read the text data from
        len - this is the length of data to decode from the text
        Returns:
        this returns the resulting byte array