zoukankan      html  css  js  c++  java
  • 工具方法

    
    
    
    
    
    
    System.getProperty("user.dir")
    + System.getProperty("file.separator")
    
    
    
    public static String amtLee2Yuan(String amt_pay) {
            int scale = 2;
            BigDecimal b1 = new BigDecimal(amt_pay);
            BigDecimal b2 = new BigDecimal(1000);
            return b1.divide(b2, scale, BigDecimal.ROUND_FLOOR).toPlainString();
        }
    
    
    
    public enum TransCodeEnum {
    
        singlePay("022C"),
        singleQuery("0228");
    
        String code;
    
        private TransCodeEnum(String code) {
            this.code = code;
        }
    
        public String getCode() {
            return this.code;
        }
    }
    
    
    
    /**
         * 为指定文本内容在前面添加“0”
         * 
         * @param content
         *            指定内容。
         * @param digit
         *            文本预置长度。
         * @return 补全空格后的文本。参数错误时返回<code>null</code>。
         */
        public static String lengthFilter(String content, int digit) {
            if (content == null) {
                content = "";
            }
            int len = content.length() - digit;
            if (len > 0) {
                logger.error("文本内容[content:" + content + ",len:" + content.length() + "]超过指定长度[len:" + digit + "]");
                return null;
            }
            StringBuffer res = new StringBuffer(digit);
            res.append(content);
            if (len < 0) {
                for (int i = 0; i < (-len); i++) {
                    res.insert(0, "0");
                }
            }
            return res.toString();
        }
    /**
         * 读文件
         * 
         * @param file
         * @return
         * @throws Exception
         */
        public static byte[] readFile(File file) {
            BufferedInputStream in = null;
            ByteArrayOutputStream out = null;
            try {
                in = new BufferedInputStream(new FileInputStream(file));
                out = new ByteArrayOutputStream();
                byte[] temp = new byte[1024];
                int size = 0;
                while ((size = in.read(temp)) != -1) {
                    out.write(temp, 0, size);
                }
                return out.toByteArray();
            } catch (Exception e) {
            } finally {
                try {
                    if (null != out)
                        out.close();
                    if (null != in)
                        in.close();
                } catch (Exception e2) {
                }
            }
            return null;
        }
    
        /**
         * 补位
         * 
         * @param byte_array
         * @return
         */
        public static byte[] paddingByte(byte[] byte_array) {
            int length = byte_array.length;
            int mode = length % 8;
            int times = 0;
            if (mode != 0)
                times = 8 - mode;
            byte[] sendByte = new byte[length + times];
            for (int i = 0; i < length; i++) {
                sendByte[i] = byte_array[i];
            }
            for (int j = length; j < length + times; j++) {
                sendByte[j] = 0x00;
            }
            return sendByte;
        }
  • 相关阅读:
    Ctfshow Web入门
    Java复习笔记
    Saliency-Guided Attention Network for Image-Sentence Matching
    根据CSV文件生成ImageFolder格式数据集,并按比例划分训练集验证集
    Context-Aware Multi-View Summarization Network for Image-Text Matching
    Classes Matter: A Fine-grained Adversarial Approach to Cross-domain Semantic Segmentation
    GINet: Graph Interaction Network for Scene Parsing
    Neural Multimodal Cooperative Learning Toward Micro-Video Understanding
    GAN&cGAN&DCGAN
    循环神经网络
  • 原文地址:https://www.cnblogs.com/lelouchKOP/p/5959567.html
Copyright © 2011-2022 走看看