Class HandlerBase64


  • public class HandlerBase64
    extends Object
    Handler of sequences of bytes for encode/decode it to base64
    Need to maintain compatibility with c++ code
    • Constructor Detail

      • HandlerBase64

        public HandlerBase64()
    • Method Detail

      • decode

        public static byte[] decode​(BufferCharReader reader)
        Read sequence of char Base64 from data and decode them
        Stop read when non base64 char will be find
        Parameters:
        reader - read from it base64 chars
        Returns:
        decoded bytes
      • decode

        public static boolean decode​(BufferCharReader reader,
                                     OutputStream writeTo)
        Read sequence of char Base64 from readFrom and decode them
        Stop read when non base64 char will be find
        Parameters:
        reader - read from it base64 chars
        writeTo - write ti it decoded bytes
        Returns:
        true, if decode
      • decode

        public static byte[] decode​(String data)
        Read sequence of char Base64 from data and decode them
        Stop read when non base64 char will be find
        Parameters:
        data - read from it base64 chars.
        Returns:
        decoded bytes
      • encode

        public static boolean encode​(InputStream readFrom,
                                     OutputStreamWriter writeTo,
                                     int lenStr,
                                     String lineSeparator)
        Encode bytes from readFrom to base64 For end line don't put separator
        Parameters:
        readFrom -
        writeTo - base64 bytes are written there
        lenStr - number of chars of base64 in one string. Must be lenStr % 4 == 0
        if lenStr == 0 then only one line
        lineSeparator - sequence of chars derived strings. Separator must be contains non base64 bytes
        Returns:
        true, if encode
      • encode

        public static boolean encode​(byte[] data,
                                     OutputStreamWriter writeTo,
                                     int lenStr,
                                     String lineSeparator)
        Encode bytes from data to base64
        Parameters:
        data -
        writeTo - base64 bytes are written there
        lenStr - number of chars of base64 in one string
        lineSeparator - sequence of chars derived strings. Separator must be contains non base64 bytes
        Returns:
        true, if encode
      • encode

        public static String encode​(InputStream readFrom,
                                    int lenStr,
                                    String lineSeparator)
        Encode bytes from readFrom to base64
        Stop read when non base64 char will be find
        Parameters:
        readFrom -
        lenStr - number of chars of base64 in one string
        lineSeparator - sequence of chars derived strings. Separator must be contains non base64 bytes
        Returns:
        base64 bytes in String
      • encode

        public static String encode​(byte[] data,
                                    int lenStr,
                                    String lineSeparator)
        Encode bytes from data to base64
        Parameters:
        data -
        lenStr - number of chars of base64 in one string
        lineSeparator - sequence of chars derived strings. Separator must be contains non base64 bytes
        Returns:
        base64 bytes in String