What does FileOutputStream.write(int b) do? [duplicate]
-
27-10-2019 - |
Question
Possible Duplicate:
Why Java OutputStream.write() Takes Integer but Writes Bytes
The documentation for FileOutputStream.write(int b)
states that it writes the byte to the file, but the argument is an integer. Could someone please clarify?
Solution
It writes the least significant byte of the int
argument to the file.
OTHER TIPS
It actually only writes the lowest order byte from that int. This was actually debated before: Why does the write(int b) method of OutputStream exist?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow