File inputFileorDirectory = new File(inputMap.get("Input File Path").toString());
LOGGER.debug("Input file or Directory is : " + inputFileorDirectory.getName());
System.out.println("Input file or Directory is : " + inputFileorDirectory.getName());
if (inputFileorDirectory.isDirectory()) {
LOGGER.debug("Input is a Directory : " + inputFileorDirectory.getName());
System.out.println("Input is a Directory : " + inputFileorDirectory.getName());
FilenameFilter fileNameFilter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if (name.endsWith("csv")) {
return true;
} else {
return false;
}
}
};
String[] inputFileNames = inputFileorDirectory.list(fileNameFilter);
if (inputFileNames == null || inputFileNames.length == 0) {
LOGGER.error("No Files present inside the directory");
System.out.println("No Files present inside the directory");
throw new Exception("No Files present inside the directory");
}
for (String inputFileName : inputFileNames) {
// Process Records
String data = readData(inputFileorDirectory.getAbsolutePath() + File.separator + inputFileName);
System.out.println("Data : " + data);
LOGGER.debug("Data : " + data);
}
}
No comments:
Post a Comment