Hi Guys,
I have a string array but each cell in the 1d string array stores each character
the text file is :
"START START START
The quick brown fox jumps over the lazy dog 1234567890-= !"$%^&*()_+ QWERTYUIOP{}ASDFGHJKL:@~|ZXCVBNM<><? /.,mnbvcxz\asdfghjkkl;'#][poiuytrewq789654123.0
+-*/``""$%£ hello this is a test file using all the characters availible on the keyboard for input END END END END"
so in the string it is:
[0] = S, [1]=A, [2]=R ...ect along the text
basically i need to convert each character in each cell of the 1d string array to its hesidecimal value .
i have created my own method which will take in a char and return a string containing the charcters hex value.
public static String toHex(char c) { char char2ascii = c; int i = 0; int num = (int) char2ascii; String hex =""; char[] digits = new char[2]; do { digits[i++] = Character.forDigit(num % 16, 16); num /= 16; } while (num != 0); for (int j = 1; j >= 0; j--){ hex += digits[j]; } hex=hex.toUpperCase(); return hex; }
what i want to do is run each cell through the toHex method so i everntally have a string array containing the hex value of each character in my text.
I understand this is long weinded but i hope u hunderstand what im trying to get at
example
i want:
String[] hexarray = S, T, A, R, T
a run it through my method to convert to hex
then it will become
String[] hexarray = 53, 54, 41, 52, 54
does anyone know how i can achive this. Im not allowed to use inbuilt libarys and classes to do the hex conversion thats why i have my own method for it .
Thank you