ciąg do HexString w Javie

import java.util.Scanner;
public class StringToHexadecimal {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter a String value: ");
      String str = sc.next();
      StringBuffer sb = new StringBuffer();
      //Converting string to character array
      char ch[] = str.toCharArray();
      for(int i = 0; i < ch.length; i++) {
         String hexString = Integer.toHexString(ch[i]);
         sb.append(hexString);
      }
      String result = sb.toString();
      System.out.println(result);
   }
}
diego decoder