I'd like to read from a directory of files rather than just 1 file Java, I've got most of this setup, I'm just stuck as how to make it happen. I want to call generatePdf() for every file in a directory
Here is my code:
I'd like to read from a directory of files rather than just 1 file Java, I've got most of this setup, I'm just stuck as how to make it happen. I want to call generatePdf() for every file in a directory
Here is my code:
private void run() throws Exception
{
// This call here
byte[] pdfBytes = this.generatePdf();
I was thinking I could do something like this
// some more processing
}
private void callGeneratePdf(File[] listOfFiles)
{
listOfFiles = getListOfFiles(DEFAULT_FORMML_FILE);
for(File f : listOfFiles)
{
f = generatePdf(); // ???
}
}
private byte[] generatePdf() throws Exception
{
String appPrintList = "<PrintListML/>"; // Empty application specific print list; no record worksheets will be included.
String formML = PrintEngine.readFileAsString(inputFormML.getAbsolutePath());
PrintListOptions plOptions = new PrintListOptions().setIncludeRecords(true).setRequireFormMLStatusPOR(true).setRequireFormMLStatusActive(false);
PrintOptions pOptions = new PrintOptions().setItemizations(true).setSmartWorksheets(true);
// Generate the PDF
return FpsService.getPrintJob(formML, appPrintList, plOptions, pOptions);
}
private static File[] getListOfFiles(String path)
{
String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
files = listOfFiles[i].getName();
System.out.println(files);
}
}
return listOfFiles;
}
My plan was to write a new method that calls generatePdf() as many times there is files in the File array (File[]). Any help or suggestions would be much appreciated, thanks.
My plan was to write a new method that calls generatePdf() as many times there is files in the File array (File[]). Any help or suggestions would be much appreciated, thanks.