I'm bit confused about Java I/O stream. I have a case where my Inputstream is very fast (like reading file from disk) but my outputstream is very slow (like writing to http servlet response outputstream).
What happens if my file size is very large, eventually would my outputstream (piped to inputstream of the file) would throw any memory related exception and close the stream? or my outputstream write method would be blocked till outputstream data is cleared?
Is it even possible for outputstream to be full?
public void pipe(InputStream is, OutputStream os) throws IOException {
int n;
byte[] buffer = new byte[1024];
while((n = is.read(buffer)) > -1) {
os.write(buffer, 0, n); // would this get blocked if outputstream is full?
}
os.close ();
}