(Java) Write decimal/hex to a file, and not string
If I have a file, and I want to literally write '42' to it (the value, not the string), which for example is 2a in hex, how do I do it? I want to be able to use something like outfile.write(42) or outfile.write(2a) and not write the string to the file.

(I realize this is a simple question but I can't find the answer of google, probably because I don't know the correct search terms)
(Java) Write decimal/hex to a file, and not string
===

If I have a file, and I want to literally write '42' to it (the value, not the string), which for example is 2a in hex, how do I do it? I want to be able to use something like outfile.write(42) or outfile.write(2a) and not write the string to the file.

(I realize this is a simple question but I can't find the answer of google, probably because I don't know the correct search terms)