+
+ public static void copyStreamToFile(InputStream input, File outputFile) throws IOException {
+ copyStreamToFile(input, outputFile, 8192);
+ }
+
+ public static void copyStreamToFile(InputStream input, File outputFile, int bufferSize) throws IOException {
+ try (OutputStream output = new FileOutputStream(outputFile)) {
+ byte[] buffer = new byte[bufferSize];
+ int read;
+
+ while ((read = input.read(buffer)) != -1) {
+ output.write(buffer, 0, read);
+ }
+ }
+ }