import org.apache.commons.codec.binary.Base64;
public class Base64Example {
public static void main(String[] args) {
String originalText = "Hello, World!";
byte[] encodedBytes = Base64.encodeBase64(originalText.getBytes());
String encodedText = new String(encodedBytes);
System.out.println("Encoded Text: " + encodedText);
byte[] decodedBytes = Base64.decodeBase64(encodedBytes);
String decodedText = new String(decodedBytes);
System.out.println("Decoded Text: " + decodedText);
}
}
import org.apache.commons.codec.net.URLCodec;
public class URLCodecExample {
public static void main(String[] args) {
URLCodec urlCodec = new URLCodec();
try {
String encodedURL = urlCodec.encode(originalURL);
System.out.println("Encoded URL: " + encodedURL);
String decodedURL = urlCodec.decode(encodedURL);
System.out.println("Decoded URL: " + decodedURL);
} catch (Exception e) {
e.printStackTrace();
}
}
}
import org.apache.commons.codec.binary.Hex;
public class HexExample {
public static void main(String[] args) {
String originalText = "Hello, World!";
String encodedText = Hex.encodeHexString(originalText.getBytes());
System.out.println("Encoded Text: " + encodedText);
try {
String decodedText = new String(Hex.decodeHex(encodedText));
System.out.println("Decoded Text: " + decodedText);
} catch (Exception e) {
e.printStackTrace();
}
}
}