35
35
import java .io .FileOutputStream ;
36
36
import java .io .InputStream ;
37
37
import java .util .ArrayList ;
38
+ import java .util .Base64 ;
38
39
import java .util .Collection ;
39
40
import java .util .Collections ;
40
41
import java .util .Enumeration ;
@@ -431,7 +432,7 @@ public static File extractArchive(File archive, File destination) {
431
432
* @return encoded String.
432
433
*/
433
434
public static String encodePassword (String value ) {
434
- return Base64 .byteArrayToBase64 (value .getBytes ());
435
+ return Base64 .getEncoder (). encodeToString (value .getBytes ());
435
436
}
436
437
437
438
/**
@@ -441,7 +442,7 @@ public static String encodePassword(String value) {
441
442
* @return decoded String.
442
443
*/
443
444
public static String decodePassword (String value ) {
444
- return new String (Base64 .base64ToByteArray (value ));
445
+ return new String (Base64 .getDecoder (). decode (value ));
445
446
}
446
447
447
448
/**
@@ -456,7 +457,7 @@ public static String decodePassword(String value) {
456
457
*/
457
458
public static String imageToString (Image image , String format ) {
458
459
byte [] imageBytes = imageToBytes (image , format );
459
- return imageBytes != null ? Base64 .byteArrayToBase64 (imageBytes ) : null ;
460
+ return imageBytes != null ? Base64 .getEncoder (). encodeToString (imageBytes ) : null ;
460
461
}
461
462
462
463
/**
@@ -466,7 +467,7 @@ public static String imageToString(Image image, String format) {
466
467
* @return decoded Image.
467
468
*/
468
469
public static Image stringToImage (String string ) {
469
- return Toolkit .getDefaultToolkit ().createImage (Base64 .base64ToByteArray (string ));
470
+ return Toolkit .getDefaultToolkit ().createImage (Base64 .getDecoder (). decode (string ));
470
471
}
471
472
472
473
private static BufferedImage imageToBuffered (Image image ) {
0 commit comments