Why Java OutputStream.write() Takes Integer but Writes Bytes
问题 I am writing an OutputStream, just noticed this in the OutputStream interface, public abstract void write(int b) throws IOException; This call write one byte to the stream but why it takes integer as an argument? 回答1: Actually I've been working with bytes a bit lately and they can be annoying. They up-convert to ints at the slightest provocation and there is no designation to turn a number into a byte--for instance, 8l will give you a long value 8, but for byte you have to say (byte)8 On top