Java examples for java.lang:String Hex
Convert byte Char To Hex String
//package com.java2s; public class Main { public static void main(String[] argv) { char byt = 'a'; System.out.println(byteCharToHexString(byt)); }//w w w . j a v a 2 s . co m public static String byteCharToHexString(char byt) { StringBuilder strb = new StringBuilder(); String hex = Integer.toHexString(byt); if (hex.length() == 1) { hex = "0" + hex; } strb.append(hex); return strb.toString().toUpperCase(); } }