### Mime Decode and Encode

To decode a Message Body using the Base64 MIME type encoding scheme, JavaObjects are required.
See also B4J HowTo > Strings Decode and Encode > Decode and Encode Subs
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Base64.html
'Encode a string using Base64 Mime Encoding
'Parameter Plain String without any special characters
'Return Mime Encoded String
`Sub EncodeMimeString(s As String) As String
Dim joEncoder As JavaObject
Return joEncoder.InitializeStatic("java.util.Base64").RunMethodJO("getMimeEncoder",Null).RunMethod("encodeToString", Array(s.GetBytes("UTF8")))
End Sub`
'Decode an Mime encoded string using Base64 Decoding
'Parameter Mime Encoded String
'Return Decoded String
`Sub DecodeMimeString(strencoded As String) As String
Dim joDecoder As JavaObject
Dim joDecodedString As JavaObject = joDecoder.InitializeStatic("java.util.Base64").RunMethodJO("getMimeDecoder",Null).RunMethod("decode", Array(strencoded))
Return joDecodedString.InitializeNewInstance("java.lang.String",Array(joDecodedString, "utf-8")).RunMethod("toString", Null)
End Sub`
Example
Program started.
SGVsbG9Xb3JsZA==
HelloWorld

Changed: , Category: Strings Decode and Encode, File: T6C256M1864.htm, ID: 1864