I am reading a text file in Java line by line. For debugging purpose, I would like to get the hex value of the string to check how it is encoded.
For example:
This is my text-file:
äppletree
This is how I read the file:
inputCharset = Charset.forName("ISO-8859-1")BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fi), inputCharset));while ( in.ready() ) { String row = in.readLine(); System.out.println(row +" = " + toHex(row));}
The result must be for first line
äpple = E4 70 70 6C 65
How can I convert the chars of the string to the appropriate hex value?