From 46319c55f34da2763a87b09519b902b9437654ba Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期二, 18 七月 2023 11:25:43 +0800 Subject: [PATCH] 修改管线泄露初始化方法 --- src/main/java/com/ard/utils/ByteUtils.java | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/ard/utils/ByteUtils.java b/src/main/java/com/ard/utils/ByteUtils.java index 33c7856..c121eaf 100644 --- a/src/main/java/com/ard/utils/ByteUtils.java +++ b/src/main/java/com/ard/utils/ByteUtils.java @@ -2,6 +2,7 @@ import javax.xml.bind.DatatypeConverter; import java.io.ByteArrayOutputStream; +import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.zip.CRC32; @@ -14,6 +15,26 @@ **/ public class ByteUtils { /** + * byte鏁扮粍杞腑鏂囧瓧绗︿覆 + */ + public static String bytesToStringZh(byte[] bytes) { + String zhStr = ""; + try { + int position = ByteUtils.findIndexOfDoubleZero(bytes); + if (position != -1) { + byte[] result = new byte[position]; + System.arraycopy(bytes, 0, result, 0, position); + zhStr = new String(result, "GBK"); + } else { + zhStr = new String(bytes, "GBK"); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return zhStr; + } + + /** * Byte瀛楄妭杞琀ex * * @param b 瀛楄妭 -- Gitblit v1.9.3