List of usage examples for java.lang Integer toHexString
public static String toHexString(int i)
From source file:Main.java
private static String bytes2hex(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; ++i) { int v = bytes[i] & 255; if (v < 16) { sb.append('0'); }/*from www . j a va2 s .com*/ sb.append(Integer.toHexString(v)); } return sb.toString(); }
From source file:Main.java
private static String buildMd5String(byte[] md5Bytes) { StringBuilder md5String = new StringBuilder(); for (byte b : md5Bytes) { int num = b >= 0 ? b : b + 256; if (num < 16) { md5String.append("0"); }//from ww w.j a v a 2 s . c om md5String.append(Integer.toHexString(num)); } return md5String.toString(); }
From source file:Main.java
public static String getHashCode(Object obj) { return "0x" + Integer.toHexString(System.identityHashCode(obj)); }
From source file:Main.java
public static String[] bytesToHexStrings(byte[] src) { if (src == null || src.length <= 0) { return null; }/*from w w w.j a v a 2s. c om*/ String[] str = new String[src.length]; for (int i = 0; i < src.length; i++) { int v = src[i] & 0xff; String hv = Integer.toHexString(v); if (hv.length() < 2) { str[i] = "0"; } str[i] = hv; } return str; }
From source file:Main.java
public static String byteArrayToHexString(byte[] bytes) { if (bytes.length == 0) return null; StringBuilder stringBuilder = new StringBuilder(); for (byte b : bytes) { if (b < 16) stringBuilder.append("0"); stringBuilder.append(Integer.toHexString(0xff & b)); }//from w ww. j ava 2 s .c o m return stringBuilder.toString(); }
From source file:Main.java
public static String bytesToHexString(byte[] src) { if (src == null || src.length <= 0) { return ""; }//from ww w. ja va2 s .c om StringBuilder stringBuilder = new StringBuilder(""); 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(); }
From source file:Main.java
public static String toHexString(byte[] b) { if (b == null) return null; StringBuilder sb = new StringBuilder(b.length * 2); for (int i = 0; i < b.length; i++) { int v = b[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { sb.append(0);/*from www . java2s .c o m*/ } sb.append(hv); } return sb.toString(); }
From source file:Main.java
public static String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder(""); if (src == null || src.length <= 0) { return null; }/*from w w w. j av a 2s. c o m*/ 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(); }
From source file:Main.java
public static String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder(""); if (src == null || src.length <= 0) { return null; }/*from w ww .j av a2s .c o m*/ 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(); }
From source file:Main.java
public static final String byteArrayToHexString(byte[] data) { StringBuilder sb = new StringBuilder(data.length * 2); for (byte b : data) { int v = b & 0xff; if (v < 16) { sb.append('0'); }/* ww w . j a v a2 s . com*/ sb.append(Integer.toHexString(v)); } return sb.toString().toUpperCase(Locale.getDefault()); }