I'm working with editing GCT code files. I've already been able to open them fine. They are just files with hex code. I've been able to open them the following way:

byteArray = getBytesFromFile(file);
String inputString = byteArrayToString(byteArray);

So now, after editing the string I made, I want to be able to save it back to a GCT file. From searching online and looking at stuff, the code I was trying was...

String toProcess = "00D0C0DE00D0C0DE" + inputCodes + "F000000000000000";
byteArray = toProcess.getBytes();

inputCodes is just a bunch of other hex values similar to the ones being added with it from elsewhere in the program. byteArray is an attribute of the class, a simple array of bytes. offset is an int that = 0.

This makes a GCT file, but instead of writing the String as the hex values, it writes the hex values of the string. How can I output a file with the string being the hex values?