Identity IQ Pre-Iterate Rule to archive CSV file after Aggregation.
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.log4j.Logger;
private static final Logger LOGGER = Logger.getLogger(“PreIterateCSV”);
LOGGER.debug(“Enterting into PreIterateCSV rule : ”);
String fileName=(String)stats.get(“fileName”);
LOGGER.debug(“Filename : “+fileName);
String filePath=(String)stats.get(“absolutePath”);
String timeStamp = new SimpleDateFormat(“yyyyMMdd_HHmmss”).format(Calendar.getInstance().getTime());
File file =new File(filePath);
File newFile =new File(“Location” + fileName.substring(0,fileName.indexOf(‘.’)) +timeStamp+”.csv”);
try {
Files.copy(file.toPath(), newFile.toPath());
LOGGER.debug(“File “+fileName+”is copied to Archive folder”);
} catch (IOException ex)
{ LOGGER.error(“Exception in Pre-Iterate Rule: “+ex.getMessage());
}
No comments:
Post a Comment