I don't understand how the read method works.why do i need the byte array as parameter to the method?
I am sorry if that is to obvious but i am n newbie to Java.
There are several overloaded read
methods are there. If you just want to read input stream you can use read()
. But if you want to store the data after reading the input stream you should use read(byte[] b)
. Data will be stored in that array
Ref : http://docs.oracle.com/javase/7/docs/api/java/io/FileInputStream.html
As per the javadocs , it reads bytes
from input stream and puts it to byte[]
upto the length of the byte[]
. If the bytes left in input stream is less than than length of byte[]
, only the bytes left will be added to byte[]
. Rest of the values in byte[]
will not be modified and remain as it was at time of initialization.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.