From 7124bb3b5e3224d129804ec8413c052572651cbb Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 26 Sep 2017 23:01:11 +0200 Subject: [PATCH] Updated IO.copyStream to be able to specify buffer size. --- src/dorkbox/util/IO.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dorkbox/util/IO.java b/src/dorkbox/util/IO.java index 1ef194b..aeabdfb 100644 --- a/src/dorkbox/util/IO.java +++ b/src/dorkbox/util/IO.java @@ -96,7 +96,17 @@ class IO { */ public static 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. + *

+ * DOES NOT CLOSE THE STEAMS! + */ + public static + 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) {