package com.friday.custody.service.trustService.mailHandleService.util;

import org.apache.commons.lang.StringUtils;

import java.io.UnsupportedEncodingException;

/**
 * @Description
 * @Author k0051745
 * @Date: 2022/11/22
 */
public class ByteUtils {
    public static String getString(int offSet, int lastSet, byte[] bytes){
        byte[] bytes1 = new byte[lastSet-offSet];
        for (int j = offSet; j < lastSet; j++) {
            bytes1[j - offSet] = bytes[j];
        }
        String s = null;
        try {
            s = new String(bytes1,"gbk").replace(" ","");
            s = new String(s.getBytes("UTF-8"),"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return s;
    }

    private static String getSubStringFive(String param,int num){
        String afterParam = param.substring(param.length() - num);
        String newParam = param.substring(0, param.length() - num).replaceFirst("0*", "");
        if(StringUtils.isNotBlank(newParam)){
            param = newParam+"."+afterParam;
        }else{
            param = "0."+afterParam;
        }
        return param;
    }
}
