Monday, January 25, 2021

How to fetch file from SFTP (Server)?

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

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...