Common

UUID

HTTP Request

Cryptography

Common

Reflection

IO

EncodeTools Tutorial

The EncodeTools class provides methods for URL encoding, URL decoding, Base64 encoding, and Base64 decoding. These methods can be used to handle string encoding and decoding for various purposes, such as preparing strings for HTTP requests or encoding binary data.

Methods

1. urlEncode(String str)

Encodes a string using URL encoding.

Example:

String encoded = EncodeTools.urlEncode("Hello World!");
// encoded will be "Hello%20World%21"

2. urlDecode(String str)

Decodes a URL-encoded string.

Example:

String decoded = EncodeTools.urlDecode("Hello%20World%21");
// decoded will be "Hello World!"

3. base64Encode(byte[] bytes)

Encodes a byte array using Base64 encoding.

Example:

byte[] encodedBytes = EncodeTools.base64Encode("Hello World!".getBytes());
// encodedBytes will be the Base64-encoded byte array

4. base64EncodeToString(byte[] bytes)

Encodes a byte array using Base64 encoding and returns the result as a string.

Example:

String encodedString = EncodeTools.base64EncodeToString("Hello World!".getBytes());
// encodedString will be "SGVsbG8gV29ybGQh"

5. base64Decode(String str)

Decodes a Base64-encoded string.

Example:

byte[] decodedBytes = EncodeTools.base64Decode("SGVsbG8gV29ybGQh");
// decodedBytes will be the decoded byte array

6. base64DecodeToString(String str)

Decodes a Base64-encoded string and returns the result as a string.

Example:

String decodedString = EncodeTools.base64DecodeToString("SGVsbG8gV29ybGQh");
// decodedString will be "Hello World!"