android工具类
weixin_今晚不加班
这个作者很懒,什么都没留下…
展开
-
Android 十六进制字符串转十进制字符串
public static int hexStringToAlgorism(String hex) { hex = hex.toUpperCase(); int max = hex.length(); int result = 0; for (int i = max; i > 0; i--) { char c = hex.charAt(i - 1); int algorism = ...原创 2021-10-06 09:24:33 · 1982 阅读 · 0 评论 -
Android 将十六进制字符串转换为字节数组
private static String hexStr = "0123456789ABCDEF"; /** * * @param hexString * @return 将十六进制转换为字节数组 */ public static byte[] HexStringToByteArray(String hexString){ //hexString的长度对2取整,作为bytes的长度 int len = h...原创 2021-10-06 09:23:38 · 1604 阅读 · 0 评论 -
Android 十六进制字符串转换成十进制字符串
public static String SixTweenToTen(String max){ int h = Integer.parseInt(max, 16); return String.valueOf(h); }原创 2021-10-06 09:22:28 · 716 阅读 · 0 评论 -
android 将字节数组转换为16进制字符串
public static String bytes2HexStr(byte[] bytes) { if (bytes == null) { return null; } StringBuilder b = new StringBuilder(); for (int i = 0; i<bytes.length; i++) { b.append(String.format("%02x", ..原创 2021-10-06 09:19:45 · 785 阅读 · 0 评论 -
Android 以十六进制字符串表示形式返回字节数组的内容
public static String bytesToHexString(byte[] bytes) { if (bytes == null) return "null"; int iMax = bytes.length - 1; if (iMax == -1) return "[]"; StringBuilder b = new StringBuilder(); b.app..原创 2021-10-06 09:18:35 · 282 阅读 · 0 评论 -
android InputStream 转byte[]
public static byte[] streamToBytes(InputStream input) { ByteArrayOutputStream output = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int n = 0; try { while (-1 != (n = input.read(buffer))) { ...原创 2021-10-06 09:16:10 · 845 阅读 · 0 评论