I have two files on my SFTP server
xyz07012014abc.txt
xyz06072014abc.txt
I have a Java program having matchpattern as follows: month="07" and year="2014"
matchPattern = "*" + month + "*" + year + "*";
Above matchpattern gets me both the files. But, I want only following file:
xyz07012014abc.txt
How can I modify my matchpattern to get correct result.
EDIT
I am using following java method and feeding above matchpattern to it.
private void getFilesFromFTP(String sftpBase, String matchPattern) throws JSchException, SftpException{
log.debug("Downloading reward files from FTP server...");
Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;
JSch jsch = new JSch();
session = jsch.getSession(REWARDS_SFTP_USER, REWARDS_SFTP_SERVER, 22);
session.setPassword(REWARDS_SFTP_PASSWORD);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
channel = session.openChannel("sftp");
channel.connect();
channelSftp = (ChannelSftp) channel;
channelSftp.cd(sftpBase);
Vector<ChannelSftp.LsEntry> list = channelSftp.ls(matchPattern);
for (ChannelSftp.LsEntry entry : list) {
channelSftp.get(entry.getFilename(), TEMP_DIRECTORY_PATH + entry.getFilename());
}
channel.disconnect();
session.disconnect();
}