I'm currently picking up on Java IO functions and coding but am a little confused while reading through online tutorials. This is in reference to the question posted here: InputStream/OutputStream read()/write() function relevance and usage
This seemed to hint that the difference between a basic write() function and the write(byte[] bytes, int offset, int length) function is in its time efficiency, but i didn't quite get the meaning of that.
In the tutorial, it was stated:
public int read(byte[] bytes, int offset, int length) throws IOException
// Read "length" number of bytes, store in bytes array starting from offset
of index.
public int read(byte[] bytes) throws IOException
// Same as read(bytes, 0, bytes.length)
What exactly do these two lines of code do to illustrate what read() does in java IO? So does the first line read the length of the file's info OR the file's actual info itself.
To pile on more confusion, the Write() function to OutputStream was explained as follows:
"Similar to the input counterpart, the abstract superclass OutputStream declares an abstract method write() to write a data-byte to the output sink. write() takes an int. The least-significant byte of the int argument is written out; the upper 3 bytes are discarded. It throws an IOException if I/O error occurs (e.g., output stream has been closed)."
Does this mean the actual info is written in or the argument? kinda confused what the paragraph was trying to say.
public void abstract void write(int unsignedByte) throws IOException\
public void write(byte[] bytes, int offset, int length) throws IOException
// Write "length" number of bytes, from the bytes array starting from offset
of index.
public void write(byte[] bytes) throws IOException
// Same as write(bytes, 0, bytes.length)
Thanks in advance for any explanation on this.