Contact: aviboots(AT)netvision.net.il
41,379 questions
53,922 answers
573 users
public class ByteArrayToHexString { public static void main(String args[]) { byte[] bytes = {3, 10, 7, 15, 12}; String hex = ""; for (byte b : bytes) { hex += String.format("%02X", b); } System.out.print(hex); } } /* run: 030A070F0C */
public class ByteArrayToHexString { public static void main(String[] args) { String s = "JAVA C C++ C#"; byte[] bytes = s.getBytes(); StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(String.format("%02X ", b)); } System.out.println(sb.toString()); } } /* run: 4A 41 56 41 20 43 20 43 2B 2B 20 43 23 */