Class Base64Converter
- java.lang.Object
- 
- com.redwood.scheduler.infrastructure.text.api.Base64Converter
 
- 
 public class Base64Converter extends Object 
- 
- 
Constructor SummaryConstructors Constructor Description Base64Converter()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decode(byte[] base64Data)Decodes Base64 data into a byte array.static byte[]decode(byte[] base64Data, int dataLength)Decodes Base64 data into a byte array.static Stringdecode(String s)Decode the Base64 data into a String.static Stringdecode(String s, String charsetName)Decode the Base64 data into a String.static byte[]encode(byte[] rawData)Encode a byte array to the corresponding Base64 byte array.static byte[]encode(byte[] rawData, int dataLength)Convert the firstdataLengthbytes ofrawDatato the corresponding Base64 byte array.static Stringencode(String s)Encode a string using the Base64 encoding.static Stringencode(String s, String charsetName)Encode a string using the Base64 encoding.static Stringencode(String s, Charset charset)Encode a string using the Base64 encoding.static Stringencode2String(byte[] rawData)Encode a byte array to the corresponding Base64 String.
 
- 
- 
- 
Method Detail- 
encodepublic static String encode(String s) Encode a string using the Base64 encoding. This is equivalent to callingencode(String, String)and specifying the "UTF-8" character set. The following table gives some sample encodings:Example calls with their corresponding results call result encode("A") "QQ==" encode("AA") "QUE=" encode("AAA") "QUFB" encode("Å") "w4U=" encode("ÅÅ") "w4XDhQ==" encode("ÅÅÅ") "w4XDhcOF" - Parameters:
- s- the string to be Base64 encoded
- Returns:
- the Base64 encoded string
 
 - 
encodepublic static String encode(String s, String charsetName) throws UnsupportedEncodingException Encode a string using the Base64 encoding. The string is converted to bytes using the specified encoding. The following table gives some sample encodings:Example calls with their corresponding results call result Base64Converter.encode("AAA", "UTF-8") "QUFB" Base64Converter.encode("Å", "UTF-8") "w4U=" Base64Converter.encode("ÅÅÅ", "UTF-8") "w4XDhcOF" Base64Converter.encode("AAA", "ISO8859-15") "QUFB" Base64Converter.encode("Å", "ISO8859-15") "xQ==" Base64Converter.encode("ÅÅÅ", "ISO8859-15") "xcXF" - Parameters:
- s- the string to be Base64 encoded
- charsetName- the encoding to use to convert the string into bytes to encode
- Returns:
- the Base64 encoded string
- Throws:
- UnsupportedEncodingException- if the encoding is not known to the Java runtime.
- See Also:
- encode(String, Charset)
 
 - 
encodepublic static String encode(String s, Charset charset) Encode a string using the Base64 encoding. The string is converted to bytes using the specified encoding. The following table gives some sample encodings:Example calls with their corresponding results call result Base64Converter.encode("AAA", "UTF-8") "QUFB" Base64Converter.encode("Å", "UTF-8") "w4U=" Base64Converter.encode("ÅÅÅ", "UTF-8") "w4XDhcOF" Base64Converter.encode("AAA", "ISO8859-15") "QUFB" Base64Converter.encode("Å", "ISO8859-15") "xQ==" Base64Converter.encode("ÅÅÅ", "ISO8859-15") "xcXF" - Parameters:
- s- the string to be Base64 encoded
- charset- the encoding to use to convert the string into bytes to encode
- Returns:
- the Base64 encoded string
 
 - 
encodepublic static byte[] encode(byte[] rawData) Encode a byte array to the corresponding Base64 byte array.- Parameters:
- rawData- the data to encoded
- Returns:
- the Base64 encoded bytes. These bytes are equivalent to the the ASCII encoded Base64 string.
 
 - 
encode2Stringpublic static String encode2String(byte[] rawData) Encode a byte array to the corresponding Base64 String. This is equivalent to callingnew String(encode(rawData), "UTF-8").- Parameters:
- rawData- the data to encoded
- Returns:
- The Base64 encoded String.
 
 - 
encodepublic static byte[] encode(byte[] rawData, int dataLength)Convert the firstdataLengthbytes ofrawDatato the corresponding Base64 byte array.- Parameters:
- rawData- the data to encoded
- dataLength- the number of bytes to encode
- Returns:
- the Base64 encoded bytes. These bytes are equivalent to the the ASCII encoded Base64 string.
 
 - 
decodepublic static String decode(String s) Decode the Base64 data into a String. The returned String is the one created by converting the bytes into a String using the UTF-8 data encoding. The following table gives some sample decodings:Example calls with their corresponding results call result Base64Converter.decode("w6vDq8Or") "ëëë" Base64Converter.encode("QUFB")) "AAA" Base64Converter.encode("w4U=") "Å" Base64Converter.encode("w4XDhcOF") "ÅÅÅ" - Parameters:
- s- the string to decode
- Returns:
- the results of decoding the string.
 
 - 
decodepublic static String decode(String s, String charsetName) throws UnsupportedEncodingException Decode the Base64 data into a String. The returned String is the one created by converting the bytes into a String using the given encoding. The following table gives some sample decodings:Example calls with their corresponding results call result Base64Converter.decode("w6vDq8Or", "UTF-8") "ëëë" Base64Converter.decode("w6vDq8Or", "ISO8859-15") "ëëë" - Parameters:
- s- the string to decode
- charsetName- the encoding to use to convert the string into bytes to encode
- Returns:
- the results of decoding the string.
- Throws:
- UnsupportedEncodingException- if the encoding is not known to the Java runtime.
 
 - 
decodepublic static byte[] decode(byte[] base64Data) Decodes Base64 data into a byte array.- Parameters:
- base64Data- byte array containing Base64 data. This array is assumed to be a multiple of four in length.
- Returns:
- array containing decoded data.
 
 - 
decodepublic static byte[] decode(byte[] base64Data, int dataLength)Decodes Base64 data into a byte array.- Parameters:
- base64Data- byte array containing Base64 data. This array is assumed to be a multiple of four in length.
- dataLength- the number of bytes to decode
- Returns:
- array containing decoded data.
 
 
- 
 
-