JLChen
2021-11-15 1323c0b3463c5486be9d5e5310782aeb9023697c
HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/utils/ByteUtils.java
@@ -1,5 +1,6 @@
package com.hdl.sdk.common.utils;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -131,4 +132,20 @@
        }
        return -1;
    }
    /**
     * 字符串to Bytes
     * @param str 字符串
     * @return
     */
    public static byte[] stringToBytes(String str) {
        try {
            // 使用指定的字符集将此字符串编码为byte序列并存到一个byte数组中
            return str.getBytes("utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return new byte[]{};
    }
}