Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Use buffered IO
Browse files Browse the repository at this point in the history
Make use of buffered IO in CompileTask to reduce the number of read and
write system calls.
  • Loading branch information
marschall committed Jul 25, 2021
1 parent 88d25a7 commit f25fc3f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/com/alexnederlof/jasperreport/CompileTask.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.alexnederlof.jasperreport;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
Expand All @@ -13,6 +15,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -54,7 +57,8 @@ public class CompileTask implements Callable<Void> {
*/
@Override
public Void call() throws Exception {
try (OutputStream out = new FileOutputStream(destination); InputStream in = new FileInputStream(source)) {
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(destination));
InputStream in = new BufferedInputStream(new FileInputStream(source))) {
JasperCompileManager.compileReportToStream(in, out);
if (verbose) {
log.info("Compiling " + source.getName());
Expand All @@ -72,4 +76,5 @@ private void cleanUpAndThrowError(File out, Exception e) throws JRException {
}
throw new JRException("Could not compile " + source.getName(), e);
}

}

0 comments on commit f25fc3f

Please sign in to comment.