zoukankan      html  css  js  c++  java
  • Base64传输字节码转换

     1 public class Base64 {
     2     public static byte[] deCode(String src)
     3     {
     4         if (src.length() < 2)
     5         {
     6             return new byte[0];
     7         }
     8         byte dest[] = new byte[src.length() / 2];
     9         Arrays.fill(dest, (byte) 0);
    10         int index = 0;
    11         for (int ii = 0; ii < src.length() - 1; ii++)
    12         {
    13             String str = "#" + src.substring(ii, ii + 2);
    14             byte rb = (byte) Integer.decode(str).intValue();
    15             dest[index++] = rb;
    16             ii++;
    17         }
    18 
    19         return dest;
    20     }
    21 
    22     public static String enCode(byte bsrc[])
    23     {
    24         String dest = "";
    25         if (bsrc == null)
    26         {
    27             return "";
    28         }
    29         for (int ii = 0; ii < bsrc.length; ii++)
    30         {
    31             byte bb = bsrc[ii];
    32             int num;
    33             if (bb >= 0)
    34             {
    35                 num = bb;
    36             }
    37             else
    38             {
    39                 num = (bb & 0x7f) + 128;
    40             }
    41             String str = Integer.toHexString(num);
    42             if (str.length() < 2)
    43             {
    44                 str = "0" + str;
    45             }
    46             dest = dest + str.toUpperCase();
    47         }
    48 
    49         return dest;
    50     }
    51 }
  • 相关阅读:
    解决Tomcat无法shutdown进程
    ConcurrentHashMap Put()操作示例代码
    Spring Data JPA
    JAVA CAS原理
    多线程
    多线程
    java 虚拟机--新生代与老年代GC
    TCP协议中的三次握手和四次挥手
    java中volatile关键字
    Java多线程
  • 原文地址:https://www.cnblogs.com/zjwia/p/3138228.html
Copyright © 2011-2022 走看看