Package org.kissweb
Class Base64
java.lang.Object
org.kissweb.Base64
Utility methods to deal with Base64.
Author: Blake McBride
Date: 11/2/23
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
Base 64 decodestatic String
encode
(byte[] ba) Base64 encodestatic boolean
mightBeBase64
(String value) Checks if a given string is a valid Base64 string.static boolean
mightBeBinary
(String content) Determines whether the given content might be binary.
-
Constructor Details
-
Base64
public Base64()
-
-
Method Details
-
encode
Base64 encode- Parameters:
ba
- the byte array to be converted to a base64 string- Returns:
- the base64 string representation of a byte array
-
decode
Base 64 decode- Parameters:
s
- the base64 encoded string- Returns:
- the decoded byte array
- Throws:
IOException
-
mightBeBase64
Checks if a given string is a valid Base64 string. Iftrue
is returned, it does not guarantee that the input string is a base64 string. It only guarantees that it is a valid base64 string.
For example:isBase64("find") == true
because is can be interpreted as a base64 but isn't intended to be a base64 string.
So, this method does not tell you if a string is a base64 string. It merely tells you if it can be interpreted as a base64 string.- Parameters:
value
- the string to be checked- Returns:
- true if the string is a valid Base64 string, false otherwise
-
mightBeBinary
Determines whether the given content might be binary.- Parameters:
content
- the content to be checked- Returns:
- true if the content might be binary, false if it's likely to be text
-