Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import java.io.File;
  2. import java.util.Collection;
  3.  
  4. import net.sf.jasperreports.engine.JRException;
  5. import net.sf.jasperreports.engine.JasperCompileManager;
  6.  
  7. import org.apache.commons.io.FileUtils;
  8. import org.apache.commons.io.filefilter.RegexFileFilter;
  9. import org.apache.commons.io.filefilter.TrueFileFilter;
  10.  
  11. /*
  12. * @author Dagvadorj Galbadrakh <dagvadorj@gmail.com>
  13. */
  14. public class JasperCompiler {
  15.  
  16. public static void main(String[] args) throws JRException {
  17.  
  18. // Get currently running directory
  19. String currentPath = System.getProperty("user.dir");
  20.  
  21. System.out.println("Current path is: " + currentPath);
  22.  
  23. // Go to directory where all the reports are
  24. File rootDir = new File(currentPath + "/WebContent/reports");
  25.  
  26. // Get all *.jrxml files
  27. Collection<File> files = FileUtils.listFiles(rootDir,
  28. new RegexFileFilter("^(.*\\.jrxml)"), TrueFileFilter.INSTANCE);
  29.  
  30. for (File file : files) {
  31. System.out.println("Compiling: " + file.getAbsolutePath());
  32. System.out.println("Output: " + file.getName() + ".jasper");
  33. // Actual compiling
  34. JasperCompileManager.compileReportToFile(file.getAbsolutePath(),
  35. "WebContent/reports/" + file.getName() + ".jasper");
  36. System.out.println("Compiling: completed!");
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement