javasftpls_JavaChannelSftp.ls⽅法代碼⽰例
本⽂整理匯總了Java中com.jcraft.jsch.ChannelSftp.ls⽅法的典型⽤法代碼⽰例。如果您正苦於以下問題:Java ChannelSftp.ls⽅法的具體⽤法?Java ChannelSftp.ls怎麽⽤?Java ChannelSftp.ls使⽤的例⼦?那麽恭喜您, 這裏精選的⽅法代碼⽰例或許可以為您提供幫助。您也可以進⼀步了解該⽅法所在類com.jcraft.jsch.ChannelSftp的⽤法⽰例。
在下⽂中⼀共展⽰了ChannelSftp.ls⽅法的19個代碼⽰例,這些例⼦默認根據受歡迎程度排序。您可以為喜歡或者感覺有⽤的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼⽰例。
⽰例1: getRemoteFileList
點讚 5
import com.jcraft.jsch.ChannelSftp; //導⼊⽅法依賴的package包/類
@SuppressWarnings("unchecked")
public static Vector getRemoteFileList(String user, String password, String addr, int port, String cwd) throws JSchException,
SftpException, Exception {
Session session = getSession(user, password, addr, port);
Vector lsVec=null;
Channel channel = session.openChannel("sftp");
ChannelSftp sftpChannel = (ChannelSftp) channel;
try {
lsVec=(Vector)sftpChannel.ls(cwd); //sftpChannel.lpwd()
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
channel.disconnect();
session.disconnect();
}
return lsVec;
}
開發者ID:billchen198318,項⽬名稱:bamboobsc,代碼⾏數:22,
⽰例2: getDir
點讚 5
import com.jcraft.jsch.ChannelSftp; //導⼊⽅法依賴的package包/類
private void getDir(final ChannelSftp channel,
final String remoteFile,
final File localFile) throws IOException, SftpException { String pwd = remoteFile;
if (remoteFile.lastIndexOf('/') != -1) {
if (remoteFile.length() > 1) {
pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/')); }
}
channel.cd(pwd);
if (!ists()) {
localFile.mkdirs();
}
@SuppressWarnings("unchecked")
final List files = channel.ls(remoteFile);
for (ChannelSftp.LsEntry le : files) {
final String name = le.getFilename();
if (le.getAttrs().isDir()) {
if (".".equals(name) || "..".equals(name)) {
continue;
}
getDir(channel,
channel.pwd() + "/" + name + "/",
new File(localFile, le.getFilename()));
} else {
getFile(channel, le, localFile);
}
}
channel.cd("..");mkdirs方法
}
開發者ID:apache,項⽬名稱:ant,代碼⾏數:31,
⽰例3: listFiles
點讚 5
import com.jcraft.jsch.ChannelSftp; //導⼊⽅法依賴的package包/類
/**
* Lists directory files on remote server.
* @throws URISyntaxException
* @throws JSchException
* @throws SftpException
*/
private void listFiles() throws URISyntaxException, JSchException, SftpException {
JSch jsch = new JSch();
JSch.setLogger(new JschLogger());
setupSftpIdentity(jsch);
URI uri = new URI(sftpUrl);
Session session = Session(sshLogin, Host(), 22);
session.setConfig("StrictHostKeyChecking", "no");
System.out.println("Connected to SFTP server");
Channel channel = session.openChannel("sftp");
ChannelSftp sftpChannel = (ChannelSftp) channel;
Vector directoryEntries = sftpChannel.Path());
for (LsEntry file : directoryEntries) {
System.out.println(String.format("File - %s", Filename()));
}
session.disconnect();
}
開發者ID:szaqal,項⽬名稱:KitchenSink,代碼⾏數:29,
⽰例4: listEntries
點讚 4
import com.jcraft.jsch.ChannelSftp; //導⼊⽅法依賴的package包/類
private Vector listEntries(final ChannelSftp channelSftp, final String path) throws SftpException { final Vector vector = new Vector();
LsEntrySelector selector = new LsEntrySelector() {
public int select(LsEntry entry) {
final String filename = Filename();
if (filename.equals(".") || filename.equals("..")) {
return CONTINUE;
}
if (Attrs().isLink()) {
vector.addElement(entry);
}
else if (Attrs().isDir()) {
if (keepDirectory(filename)) {
vector.addElement(entry);
}
}
else {
if (keepFile(filename)) {
vector.addElement(entry);
}
}
return CONTINUE;
}
};
channelSftp.ls(path, selector);
return vector;
}
開發者ID:archos-sa,項⽬名稱:aos-FileCoreLibrary,代碼⾏數:30,⽰例5: ls
點讚 4
import com.jcraft.jsch.ChannelSftp; //導⼊⽅法依賴的package包/類@Override
@SuppressWarnings("unchecked")
public List ls(String path)
throws FileBasedHelperException {
try {
List list = new ArrayList();
ChannelSftp channel = getSftpChannel();
Vector vector = channel.ls(path);
for (LsEntry entry : vector) {
list.Filename());
}
channel.disconnect();
return list;
} catch (SftpException e) {
throw new FileBasedHelperException("Cannot execute ls command on sftp connection", e);
}
}
開發者ID:Hanmourang,項⽬名稱:Gobblin,代碼⾏數:18,
⽰例6: ls
點讚 3
import com.jcraft.jsch.ChannelSftp; //導⼊⽅法依賴的package包/類
public static List ls(String hostname, int port, String username, File keyFile, final String passphrase, String path) throws JSchException, IOException, SftpException {
Session session = createSession(hostname, port, username, keyFile, passphrase);
ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
@SuppressWarnings("unchecked")
Vector vector = (Vector) channel.ls(path);
channel.disconnect();
session.disconnect();
List files = new ArrayList();
for (LsEntry lse : vector) {
files.Filename());
}
return files;
}
開發者ID:ujmp,項⽬名稱:universal-java-matrix-package,代碼⾏數:17,

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。