The reason why you cannot use the method write(int b) to export an integer to the output stream is because, what really happens is that you write raw binary data to the stream. What is written on the stream is not the integer value, but instead the 8 lower bits of this integer, i.e. a single byte. The higher 24 bits (or 3 bytes) of the integer b are just discarded by the method.
If you use this method, you have to handle the translation of your integer value to raw binary sequences that can be properly displayed by the charset used by the system.
If for example, you need to store the integer value 10 in Unicode, based on this table here, you would need to write two bytes to the stream:
Doing this translation manually makes things a bit more complicated. That's why, you are better off using a String and letting the getBytes method do the translation for you.
outputstream.write(49); //this writes the integer 1, in HEX 31
outputstream.write(48); //this writes the integer 0, in HEX 30