Copying Input Stream to Output Stream
suggest changeThis function copies data between two streams -
void copy(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[8192];
while ((bytesRead = in.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
}
}
Example -
// reading from System.in and writing to System.out
copy(System.in, System.out);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents