List of usage examples for java.lang Integer toHexString
public static String toHexString(int i)
From source file:Main.java
public static String toHexString(String s) { String str = ""; for (int i = 0; i < s.length(); ++i) { char ch = s.charAt(i); String s4 = Integer.toHexString(ch); str = str + s4;//from w w w .j av a2 s. c o m } return str; }
From source file:Main.java
public static String asciiToHex(String ascii) { StringBuilder hex = new StringBuilder(); for (int i = 0; i < ascii.length(); i++) { hex.append(Integer.toHexString(ascii.charAt(i))); }//w w w. jav a2s .com return hex.toString(); }
From source file:Main.java
private static String byteToHexString(byte[] digest) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < digest.length; i++) { String hex = Integer.toHexString(0xFF & digest[i]); if (hex.length() == 1) { sb.append('0'); }//from w w w .ja v a2 s. c o m sb.append(hex); } return sb.toString(); }
From source file:Main.java
public static String byteToPdu(int b) { StringBuffer sb = new StringBuffer(); String s = Integer.toHexString(b & 0xFF); if (s.length() == 1) { sb.append("0"); }//from ww w.java 2 s.c o m sb.append(s); return sb.toString().toUpperCase(); }
From source file:Main.java
public static String toString(byte[] theByteArray) { StringBuffer out = new StringBuffer(); for (int i = 0; i < theByteArray.length; i++) { String s = Integer.toHexString(theByteArray[i] & 0xff); if (s.length() < 2) { out.append('0'); }/*ww w . j ava 2s . co m*/ out.append(s).append(' '); } return out.toString(); }
From source file:Main.java
public static final String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(bytes[i] & 0xFF); if (hex.length() == 1) { hex = '0' + hex; }// ww w. ja v a2s . co m sb.append(hex); } return sb.toString(); }
From source file:Main.java
public static String toHexString(String s) { String str = ""; for (int i = 0; i < s.length(); i++) { int ch = (int) s.charAt(i); String s4 = Integer.toHexString(ch); str = str + s4;/*w w w . jav a 2 s .c o m*/ } return str; }
From source file:Main.java
public static String decodeByteToHexString(byte src) { byte[] des = new byte[2]; des[1] = (byte) (src & 0x0f); des[0] = (byte) ((src & 0xf0) >> 4); return Integer.toHexString(des[0]) + Integer.toHexString(des[1]); }
From source file:Main.java
private static String bytesToHexString(byte[] bytes) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(0xFF & bytes[i]); if (hex.length() == 1) { builder.append("0"); }/*from w w w . ja va 2s .co m*/ builder.append(hex); } return builder.toString(); }
From source file:Main.java
public static String getHexStr(byte[] buffer) { String hexStr = ""; if (buffer != null) { for (byte b : buffer) { String temp = Integer.toHexString(b & 0xFF); if (temp.length() == 1) { hexStr += "0"; }//from w w w. jav a 2s . co m hexStr += temp + " "; } } return hexStr.toUpperCase(); }