From a26c074129afced8fe87e300fb501030fde0c056 Mon Sep 17 00:00:00 2001
From: chengf <2156125618@qq.com>
Date: 星期五, 04 七月 2025 18:38:29 +0800
Subject: [PATCH] 添加二级费用项
---
java110-utils/src/main/java/com/java110/utils/util/Base64Convert.java | 29 ++++++++++++++++++++++++-----
1 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/java110-utils/src/main/java/com/java110/utils/util/Base64Convert.java b/java110-utils/src/main/java/com/java110/utils/util/Base64Convert.java
old mode 100644
new mode 100755
index 264e277..23edb02
--- a/java110-utils/src/main/java/com/java110/utils/util/Base64Convert.java
+++ b/java110-utils/src/main/java/com/java110/utils/util/Base64Convert.java
@@ -1,12 +1,13 @@
package com.java110.utils.util;
-import sun.misc.BASE64Decoder;
-import sun.misc.BASE64Encoder;
-
import java.io.*;
+
+import org.apache.commons.codec.binary.Base64;
public class Base64Convert {
+ private static final Base64 base64 = new Base64();
+
private void Base64Convert() {
}
@@ -25,7 +26,7 @@
byte[] bytes = new byte[in.available()];
// 灏嗘枃浠朵腑鐨勫唴瀹硅鍏ュ埌鏁扮粍涓�
in.read(bytes);
- strBase64 = new BASE64Encoder().encode(bytes); //灏嗗瓧鑺傛祦鏁扮粍杞崲涓哄瓧绗︿覆
+ strBase64 = base64.encodeToString(bytes); //灏嗗瓧鑺傛祦鏁扮粍杞崲涓哄瓧绗︿覆
} finally {
if (in != null) {
in.close();
@@ -36,14 +37,32 @@
}
/**
+ * 娴佽浆鎹负瀛楃涓�
+ *
+ * @param bytes
+ * @return
+ * @throws IOException
+ */
+ public static String byteToBase64(byte[] bytes) {
+ String strBase64 = null;
+ // in.available()杩斿洖鏂囦欢鐨勫瓧鑺傞暱搴�
+ strBase64 = base64.encodeToString(bytes); //灏嗗瓧鑺傛祦鏁扮粍杞崲涓哄瓧绗︿覆
+ return strBase64;
+ }
+
+
+
+
+ /**
* 灏哹ase64 杞负瀛楄妭
+ *
* @param strBase64
* @return
* @throws IOException
*/
public static byte[] base64ToByte(String strBase64) throws IOException {
// 瑙g爜锛岀劧鍚庡皢瀛楄妭杞崲涓烘枃浠�
- byte[] bytes = new BASE64Decoder().decodeBuffer(strBase64); //灏嗗瓧绗︿覆杞崲涓篵yte鏁扮粍
+ byte[] bytes = base64.decode(strBase64); //灏嗗瓧绗︿覆杞崲涓篵yte鏁扮粍
return bytes;
}
}
--
Gitblit v1.8.0