这个还是前段时间在做jni的时候遇到的问题。
几个数据类型的转换。
留下了,以备后用。
/** * 数据类型转换方法 */ //转换bytesToHexString public static String bytesToHexString(byte[] src){ StringBuilder stringBuilder = new StringBuilder(""); if (src == null || src.length <= 0) { return null; } for (int i = 0; i < src.length; i++) { int v = src[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { stringBuilder.append(0); } stringBuilder.append(hv); } return stringBuilder.toString(); } //long2byte public static byte[] long2Bytes(long l){ byte[] bytes = new byte[8]; for (int j = 7; j >=0 ; j--) { byte b = (byte)(l & 0xff); bytes[j] = b; l >>= 8; } return bytes; }