asked on
private String fillFilesProcessedReport(String vendor, String logPath)
{
String content ="";
String line="";
String[] splitResults;
ArrayList fileNames = new ArrayList();
ArrayList fileContents= new ArrayList();
String fileName="";
String indexContents="";
maxIndexFileNameLength=19;
processedCnt=0;
if(vendorNumber == 0 )
{
content += "The following files have been processed succesfully through the LifeFTP Process.\n";
//content += "Please click here for the excel spreadsheet: \\\\svdw-img1\\image\\FTP\\LifeFTPCRL\\Logs\\output.csv \n\n.";
content += rPad("Vendor",12 )+ rPad("Index File", maxIndexFileNameLength+2) + "File Contents\n";
content += rPad("----------",12) + rPad("----------", maxIndexFileNameLength+2) + "-------------\n";
}
BufferedWriter bw = null;
try
{
String reportFileName = logPath+ "_FilesProcessedReport.txt";
log.info("fillFilesProcessedReport(): "+reportFileName);
BufferedReader reportReader = new BufferedReader(new FileReader(reportFileName));
line = reportReader.readLine();
File file = new File ("C:/output.csv");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file);
bw = new BufferedWriter(fw);
while(line != null)
{
splitResults=line.split("\\*");
if(splitResults[0].length() > maxIndexFileNameLength)
{
maxIndexFileNameLength = splitResults[0].length();
}
fileNames.add(splitResults[0]);
fileContents.add(splitResults[1]);
processedCnt++;
line = reportReader.readLine();
}
reportReader.close();
for(int i = 0; i < fileNames.size(); i++)
{
fileName = (String)fileNames.get(i);
indexContents = (String)fileContents.get(i);
content += rPad(vendor,12)+ rPad(fileName,maxIndexFileNameLength+2) +indexContents + "\n";
bw.write(content);
}
bw.close();
}
catch(Exception ex)
{
log.error("fillFilesProcessedReport(): " + ex.toString());
return content;
}
return content;
}