Class HttpRequest.Base64
java.lang.Object
com.github.kevinsawicki.http.HttpRequest.Base64
- Enclosing class:
HttpRequest
Encodes and decodes to and from Base64 notation.
I am placing this code in the Public Domain. Do with it as you will. This software comes with no guarantees or warranties but with plenty of well-wishing instead! Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.
- Version:
- 2.3.7
- Author:
- Robert Harder, rob@iharder.net
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncode string as a byte array in Base64 annotation.static StringencodeBytes(byte[] source) Encodes a byte array into Base64 notation.static StringencodeBytes(byte[] source, int off, int len) Encodes a byte array into Base64 notation.static byte[]encodeBytesToBytes(byte[] source, int off, int len) Similar toencodeBytes(byte[], int, int)but returns a byte array instead of instantiating a String.
-
Method Details
-
encode
-
encodeBytes
Encodes a byte array into Base64 notation.- Parameters:
source- The data to convert- Returns:
- The Base64-encoded data as a String
- Throws:
NullPointerException- if source array is nullIllegalArgumentException- if source array, offset, or length are invalid- Since:
- 2.0
-
encodeBytes
Encodes a byte array into Base64 notation.- Parameters:
source- The data to convertoff- Offset in array where conversion should beginlen- Length of data to convert- Returns:
- The Base64-encoded data as a String
- Throws:
NullPointerException- if source array is nullIllegalArgumentException- if source array, offset, or length are invalid- Since:
- 2.0
-
encodeBytesToBytes
public static byte[] encodeBytesToBytes(byte[] source, int off, int len) Similar toencodeBytes(byte[], int, int)but returns a byte array instead of instantiating a String. This is more efficient if you're working with I/O streams and have large data sets to encode.- Parameters:
source- The data to convertoff- Offset in array where conversion should beginlen- Length of data to convert- Returns:
- The Base64-encoded data as a String if there is an error
- Throws:
NullPointerException- if source array is nullIllegalArgumentException- if source array, offset, or length are invalid- Since:
- 2.3.1
-