Created
October 25, 2012 03:16
-
-
Save dagvadorj/3950235 to your computer and use it in GitHub Desktop.
Compiling jrxml to binary jasper reports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]> | |
*/ | |
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!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment