diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/FileBodyHandler.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/FileBodyHandler.java index d2484bf146444..de2b80663a2f7 100644 --- a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/FileBodyHandler.java +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/FileBodyHandler.java @@ -36,11 +36,7 @@ public File readFrom(Class type, Type genericType, } try (OutputStream output = new BufferedOutputStream(new FileOutputStream(downloadedFile))) { - int read; - final byte[] buf = new byte[2048]; - while ((read = entityStream.read(buf)) != -1) { - output.write(buf, 0, read); - } + entityStream.transferTo(output); } return downloadedFile; diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/InputStreamMessageBodyHandler.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/InputStreamMessageBodyHandler.java index b5eb4010aadc2..383464b513a18 100644 --- a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/InputStreamMessageBodyHandler.java +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/InputStreamMessageBodyHandler.java @@ -34,11 +34,7 @@ public void writeTo(InputStream inputStream, Class type, Type genericType, An protected void writeTo(InputStream inputStream, OutputStream entityStream) throws IOException { try { - byte[] buffer = new byte[8192]; - int c; - while ((c = inputStream.read(buffer)) != -1) { - entityStream.write(buffer, 0, c); - } + inputStream.transferTo(entityStream); } finally { try { inputStream.close();