I am trying to read the mails from the MS Exchange by using camel
and getting the attachments as DataHandler
. A 10MB
file takes around 3hrs
to write into the location.
File outputFile = new File(someDirectory, someFileName);
DataHandler attachment_data = destination1Attachments.get("someFileName.txt");
try (FileOutputStream fos = new FileOutputStream(outputFile)) {
attachment_data.writeTo(fos);
}
I have also noticed that sometimes a 6 to 7Mb file takes around 2 to 3 minutes and when another mail comes just after that it takes more time than expected.
Because of GC ?
Trying to find the exact root cause or any other method to write the data to the file.
Update 1 :
Tried using BufferedOutputStream
around FileOutputSteam
as mentioned by @user207421 in the comment. No much change could find (just 1sec or little more).