public static void longToAscString

来源:互联网 发布:js 获取元素父节点 编辑:程序博客网 时间:2024/05/02 00:25

/**
  * 把long型转换成明文asc string 不足位用空格填充
  */
 public static void longToAscString(long from, byte[] to, int offset,
   int size, String encode) {
  try {
   byte[] temp = new byte[size];
   byte[] lenStr = (from + "").getBytes(encode);

   for (int i = 0; i < temp.length; i++) {
    temp[i] = " ".getBytes(encode)[0];
   }
   copyData(temp, size - lenStr.length, lenStr, lenStr.length);
   copyData(to, offset, temp, temp.length);
  } catch (Exception e) {
   // e.printStackTrace();
  }
 }

原创粉丝点击