List of usage examples for java.lang Integer toHexString
public static String toHexString(int i)
From source file:Main.java
/** * Convert char(uint8) to Hex String//from ww w. j a v a 2 s . com * * @param u8 * the char(uint8) to be converted * @return the Hex String */ public static String convertU8ToHexString(char u8) { return Integer.toHexString(u8); }
From source file:Main.java
private static String byte2String(byte[] b) { StringBuilder hs = new StringBuilder(); String stmp;/* ww w . j a v a 2s. com*/ for (int n = 0; b != null && n < b.length; n++) { stmp = Integer.toHexString(b[n] & 0XFF); if (stmp.length() == 1) hs.append('0'); hs.append(stmp); } return hs.toString().toUpperCase(Locale.CHINA); }
From source file:Main.java
public static String a(byte[] arg5) { StringBuilder v1 = new StringBuilder(); int v0;/* www. ja va2 s . co m*/ for (v0 = 0; v0 < arg5.length; ++v0) { String v2 = Integer.toHexString(arg5[v0] & 255); if (v2.length() == 1) { v1.append("0").append(v2); } else { v1.append(v2); } } return v1.toString(); }
From source file:Main.java
public static String string2HexString(String str) { StringBuffer hexString = new StringBuffer(); for (int i = 0; i < str.length(); i++) { int ch = (int) str.charAt(i); String strHex = Integer.toHexString(ch); hexString.append(strHex);/*from w w w.j av a 2 s . com*/ } return hexString.toString(); }
From source file:Main.java
private static String _bytes2Hex(byte[] b) { StringBuilder builder = new StringBuilder(); String stmp = ""; for (int i = 0; i < b.length; i++) { stmp = Integer.toHexString(b[i] & 0xFF); if (stmp.length() == 1) { builder.append("0" + stmp); } else {/* w w w .j a va 2 s . c om*/ builder.append(stmp); } } return builder.toString().toUpperCase(Locale.getDefault()); }
From source file:Main.java
public static String string2Unicode(String string) { StringBuffer unicode = new StringBuffer(); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); unicode.append("\\" + "u" + Integer.toHexString(c)); }/*from www . j a v a 2s. c om*/ return unicode.toString(); }
From source file:Main.java
private static String byte2hex(byte[] b) { StringBuilder hs = new StringBuilder(); String stmp;/*from ww w . ja va 2s . c o m*/ for (int n = 0; b != null && n < b.length; n++) { stmp = Integer.toHexString(b[n] & 0XFF); if (stmp.length() == 1) hs.append('0'); hs.append(stmp); } return hs.toString().toUpperCase(); }
From source file:Main.java
public static String byteArrayToHexString(byte[] value) { StringBuilder stringBuilder = new StringBuilder(""); for (int i = 0; i < value.length; i++) { int v = value[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { stringBuilder.append(0);/* ww w.j a v a 2 s . c o m*/ } stringBuilder.append(hv); } return stringBuilder.toString(); }
From source file:Main.java
public static String byteArray2HexString(byte[] bytes) { if (null == bytes) { return ""; }/* w w w .j a v a 2 s .co m*/ StringBuilder hexString = new StringBuilder(); for (byte b : bytes) { String str = Integer.toHexString(0xFF & b); while (str.length() < 2) { str = "0" + str; } hexString.append(str); } return hexString.toString(); }
From source file:Main.java
public static String scanByteToHexString(byte[] scanRecord) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < scanRecord.length; i++) { int v = scanRecord[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { stringBuilder.append(0);// w w w . j a v a2 s. c o m } stringBuilder.append(hv); } return stringBuilder.toString(); }