Hi All,
I have come across Read and write method from InputStream and outputstream but im finding it hard to understand the logic behind it.
Below is a simple example which reads a jar file from input stream and writes it to output stream. Please explain the logic on how this reading and writing happens .
** Please assume other parameters in below code are defined/intialised properly **
InputStream is = ctx.getResourceAsStream("/bookcode.jar");
int read = 0;
byte[] bytes = new byte[1024];
OutputStream os = response.getOutputStream();
while((read = is.read(bytes) != -1) {
os.write(bytes,0,read);
}
os.flush();
os.close();
}
** what will happen when i change bytes size to something other than 1024 for example 20 or 30... and
What is happening in while condition statement and body ?
Thanks in advance