Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
1
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
35
// {
String string = "some random data";
// Encoding
Encoder encoder = Base64.getEncoder();
byte[] data = string.getBytes(UTF_8);
String encodedString = encoder.encodeToString(data);
System.out.println("Encoded: " + encodedString);
// Decoding
Decoder decoder = Base64.getDecoder();
byte[] bytes = decoder.decode(encodedString);
String decodedString = new String(bytes, UTF_8);
System.out.println("Decoded: " + decodedString);
//{
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content