use of com.talend.csv.CSVWriter in project tdq-studio-se by Talend.
the class ReportFileHelper method saveReportListFile.
/**
* DOC xqliu Comment method "saveReportListFile".
*
* @param reportListFile
* @param repList
* @throws IOException
* @throws PersistenceException
*/
public static void saveReportListFile(final File reportListFile, final List<ReportListParameters> repList) throws PersistenceException {
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit(ProjectManager.getInstance().getCurrentProject(), // $NON-NLS-1$
"saveReportListFile") {
@Override
protected void run() throws LoginException, PersistenceException {
try {
CSVWriter out = FileUtils.createCSVWriter(reportListFile, FileUtils.TEXT_QUAL, FileUtils.ESCAPE_CHAR);
ReportListEnum[] values = ReportListEnum.values();
String[] temp = new String[values.length];
for (int i = 0; i < repList.size() + 1; i++) {
if (i == 0) {
temp[0] = ReportListEnum.Name.getLiteral();
temp[1] = ReportListEnum.Path.getLiteral();
temp[2] = ReportListEnum.CreateTime.getLiteral();
} else {
temp[0] = repList.get(i - 1).name;
temp[1] = repList.get(i - 1).path;
temp[2] = repList.get(i - 1).createTime;
}
out.writeNext(temp);
}
out.flush();
out.close();
} catch (FileNotFoundException e) {
log.error(e);
} catch (IOException e) {
log.error(e);
}
}
};
repositoryWorkUnit.setAvoidUnloadResources(true);
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
repositoryWorkUnit.throwPersistenceExceptionIfAny();
}
Aggregations