2021与蓝度共同重构项目,服务端
liuhaonan
2022-02-14 0d75b97f3dc35013f1b6dca1b639e16275bfc95d
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/HexStrConvertUtil.java
@@ -1,5 +1,7 @@
package com.sandu.ximon.admin.utils;
import java.util.ArrayList;
/**
 * 16
 */
@@ -71,25 +73,25 @@
     * @return: int
     * @description: 十六进制转十进制
     */
    public static int HexToInt(String content){
        int number=0;
        String [] HighLetter = {"A","B","C","D","E","F"};
        Map<String,Integer> map = new HashMap<>();
        for(int i = 0;i <= 9;i++){
            map.put(i+"",i);
        }
        for(int j= 10;j<HighLetter.length+10;j++){
            map.put(HighLetter[j-10],j);
        }
        String[]str = new String[content.length()];
        for(int i = 0; i < str.length; i++){
            str[i] = content.substring(i,i+1);
        }
        for(int i = 0; i < str.length; i++){
            number += map.get(str[i])*Math.pow(16,str.length-1-i);
        }
        return number;
    }
//    public static int HexToInt(String content){
//        int number=0;
//        String [] HighLetter = {"A","B","C","D","E","F"};
//        Map<String,Integer> map = new HashMap<>();
//        for(int i = 0;i <= 9;i++){
//            map.put(i+"",i);
//        }
//        for(int j= 10;j<HighLetter.length+10;j++){
//            map.put(HighLetter[j-10],j);
//        }
//        String[]str = new String[content.length()];
//        for(int i = 0; i < str.length; i++){
//            str[i] = content.substring(i,i+1);
//        }
//        for(int i = 0; i < str.length; i++){
//            number += map.get(str[i])*Math.pow(16,str.length-1-i);
//        }
//        return number;
//    }
    /**
@@ -116,8 +118,9 @@
        String sTemp;
        for (int i = 0; i < bArray.length; i++) {
            sTemp = Integer.toHexString(0xFF & bArray[i]);
            if (sTemp.length() < 2)
            if (sTemp.length() < 2) {
                sb.append(0);
            }
            sb.append(sTemp.toLowerCase());
        }
        return sb.toString();
@@ -127,8 +130,9 @@
        StringBuffer sb = new StringBuffer();
        String sTemp;
        sTemp = Integer.toHexString(0xFF & b);
        if (sTemp.length() < 2)
        if (sTemp.length() < 2) {
            sb.append(0);
        }
        sb.append(sTemp.toLowerCase());
        return sb.toString();
    }
@@ -328,30 +332,30 @@
    }
    public static byte[] readInputStream(InputStream inputStream) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        if (inputStream != null) {
            try {
                byte[] buffer = new byte[91];
                int counts;
                while ((counts = inputStream.read(buffer, 0, buffer.length)) > 0) {
                    byteArrayOutputStream.write(buffer, 0, counts);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }/* finally {
                if (byteArrayOutputStream != null) {
                    try {
                        byteArrayOutputStream.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }*/
        }
        return byteArrayOutputStream.toByteArray();
    }
//    public static byte[] readInputStream(InputStream inputStream) {
//        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//
//        if (inputStream != null) {
//            try {
//                byte[] buffer = new byte[91];
//                int counts;
//                while ((counts = inputStream.read(buffer, 0, buffer.length)) > 0) {
//                    byteArrayOutputStream.write(buffer, 0, counts);
//                }
//            } catch (IOException e) {
//                e.printStackTrace();
//            }/* finally {
//                if (byteArrayOutputStream != null) {
//                    try {
//                        byteArrayOutputStream.close();
//                    } catch (IOException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }*/
//        }
//        return byteArrayOutputStream.toByteArray();
//    }
    //                br = new BufferedReader(new InputStreamReader(inputStream));
//                byteArrayOutputStream = new ByteArrayOutputStream();