use of com.jcraft.jsch.ChannelSftp.LsEntry in project opennms by OpenNMS.
the class Sftp3gppUrlConnection method getFileList.
/**
* Gets the file list (from the path defined on the URL).
*
* @return the file list
* @throws SftpException the SFTP exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
public List<String> getFileList() throws SftpException, IOException {
List<String> files = new ArrayList<String>();
Vector<LsEntry> entries = getChannel().ls(url.getPath());
for (LsEntry entry : entries) {
if (entry.getFilename().startsWith("."))
continue;
files.add(entry.getFilename());
}
Collections.sort(files);
return files;
}
use of com.jcraft.jsch.ChannelSftp.LsEntry in project bamboobsc by billchen198318.
the class SFtpClientUtils method getRemoteFileList.
@SuppressWarnings("unchecked")
public static Vector<LsEntry> getRemoteFileList(String user, String password, String addr, int port, String cwd) throws JSchException, SftpException, Exception {
Session session = getSession(user, password, addr, port);
Vector<LsEntry> lsVec = null;
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
try {
//sftpChannel.lpwd()
lsVec = (Vector<LsEntry>) sftpChannel.ls(cwd);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
sftpChannel.exit();
channel.disconnect();
session.disconnect();
}
return lsVec;
}
Aggregations