Updated IO.copyStream to be able to specify buffer size.

This commit is contained in:
nathan 2017-09-26 23:01:11 +02:00
parent 7818077686
commit 7124bb3b5e
1 changed files with 11 additions and 1 deletions

View File

@ -96,7 +96,17 @@ class IO {
*/
public static
<T extends OutputStream> T copyStream(final ImageInputStream inputStream, final T outputStream) throws IOException {
byte[] buffer = new byte[4096];
return copyStream(4096, inputStream, outputStream);
}
/**
* Copy the contents of the input stream to the output stream.
* <p>
* DOES NOT CLOSE THE STEAMS!
*/
public static
<T extends OutputStream> T copyStream(final int bufferSize, final ImageInputStream inputStream, final T outputStream) throws IOException {
byte[] buffer = new byte[bufferSize];
int read;
while ((read = inputStream.read(buffer)) > 0) {