Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.Collection;
- import net.sf.jasperreports.engine.JRException;
- import net.sf.jasperreports.engine.JasperCompileManager;
- import org.apache.commons.io.FileUtils;
- import org.apache.commons.io.filefilter.RegexFileFilter;
- import org.apache.commons.io.filefilter.TrueFileFilter;
- /*
- * @author Dagvadorj Galbadrakh <dagvadorj@gmail.com>
- */
- public class JasperCompiler {
- public static void main(String[] args) throws JRException {
- // Get currently running directory
- String currentPath = System.getProperty("user.dir");
- System.out.println("Current path is: " + currentPath);
- // Go to directory where all the reports are
- File rootDir = new File(currentPath + "/WebContent/reports");
- // Get all *.jrxml files
- Collection<File> files = FileUtils.listFiles(rootDir,
- new RegexFileFilter("^(.*\\.jrxml)"), TrueFileFilter.INSTANCE);
- for (File file : files) {
- System.out.println("Compiling: " + file.getAbsolutePath());
- System.out.println("Output: " + file.getName() + ".jasper");
- // Actual compiling
- JasperCompileManager.compileReportToFile(file.getAbsolutePath(),
- "WebContent/reports/" + file.getName() + ".jasper");
- System.out.println("Compiling: completed!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement