本文整理汇总了Java中com.trilead.ssh2.SFTPv3Client.ls方法的典型用法代码示例。如果您正苦于以下问题:Java SFTPv3Client.ls方法的具体用法?Java SFTPv3Client.ls怎么用?Java SFTPv3Client.ls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.trilead.ssh2.SFTPv3Client
的用法示例。
在下文中一共展示了SFTPv3Client.ls方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyRecursive
import com.trilead.ssh2.SFTPv3Client; //导入方法依赖的package包/类
/**
* copy a directory from the remote host to the local one recursivly.
*
* @param sourceLocation the source directory on the remote host
* @param targetLocation the target directory on the local host
* @param sftpClient is an instance of SFTPv3Client that makes SFTP client connection over SSH-2
* @return the number of files successfully copied
* @throws Exception
*/
private void copyRecursive(String sourceLocation, String targetLocation,
SFTPv3Client sftpClient,Pattern pattern,Job parentJob) throws Exception
{
String sourceFolder="."+FTPUtils.FILE_SEPARATOR;
if (sourceLocation!=null) sourceFolder=sourceLocation;
if (this.isDirectory(sftpClient, sourceFolder)) {
Vector<?> filelist = sftpClient.ls(sourceFolder);
Iterator<?> iterator = filelist.iterator();
while (iterator.hasNext()) {
SFTPv3DirectoryEntry dirEntry = (SFTPv3DirectoryEntry) iterator .next();
if (dirEntry == null) continue;
if (dirEntry.filename.equals(".") || dirEntry.filename.equals("..")) continue;
copyRecursive(sourceFolder + FTPUtils.FILE_SEPARATOR+dirEntry.filename, targetLocation + Const.FILE_SEPARATOR
+ dirEntry.filename, sftpClient,pattern,parentJob);
}
} else if (isFile(sftpClient, sourceFolder))
{
if(getFileWildcard(sourceFolder,pattern))
copyFile(sourceFolder, targetLocation, sftpClient);
}
}
示例2: GetFiles
import com.trilead.ssh2.SFTPv3Client; //导入方法依赖的package包/类
/**
* copy a directory from the remote host to the local one.
*
* @param sourceLocation the source directory on the remote host
* @param targetLocation the target directory on the local host
* @param sftpClient is an instance of SFTPv3Client that makes SFTP client connection over SSH-2
* @return the number of files successfully copied
* @throws Exception
*/
@SuppressWarnings("unchecked")
private void GetFiles(String sourceLocation, String targetLocation,
SFTPv3Client sftpClient,Pattern pattern, Job parentJob) throws Exception
{
String sourceFolder=".";
if (!Const.isEmpty(sourceLocation))
sourceFolder=sourceLocation + FTPUtils.FILE_SEPARATOR;
else
sourceFolder+=FTPUtils.FILE_SEPARATOR;
Vector<SFTPv3DirectoryEntry> filelist = sftpClient.ls(sourceFolder);
if(filelist!=null)
{
Iterator<SFTPv3DirectoryEntry> iterator = filelist.iterator();
while (iterator.hasNext() && !parentJob.isStopped())
{
SFTPv3DirectoryEntry dirEntry = iterator.next();
if (dirEntry == null) continue;
if (dirEntry.filename.equals(".")
|| dirEntry.filename.equals("..") || isDirectory(sftpClient, sourceFolder+dirEntry.filename))
continue;
if(getFileWildcard(dirEntry.filename,pattern))
{
// Copy file from remote host
copyFile(sourceFolder + dirEntry.filename, targetLocation + FTPUtils.FILE_SEPARATOR + dirEntry.filename, sftpClient);
}
}
}
}
示例3: copyRecursive
import com.trilead.ssh2.SFTPv3Client; //导入方法依赖的package包/类
/**
* copy a directory from the remote host to the local one recursivly.
*
* @param sourceLocation the source directory on the remote host
* @param targetLocation the target directory on the local host
* @param sftpClient is an instance of SFTPv3Client that makes SFTP client connection over SSH-2
* @return the number of files successfully copied
* @throws Exception
*/
@SuppressWarnings("unchecked")
private void copyRecursive(String sourceLocation, String targetLocation,
SFTPv3Client sftpClient,Pattern pattern,Job parentJob) throws Exception
{
String sourceFolder="."+FTPUtils.FILE_SEPARATOR;
if (sourceLocation!=null) sourceFolder=sourceLocation;
if (this.isDirectory(sftpClient, sourceFolder)) {
Vector filelist = sftpClient.ls(sourceFolder);
Iterator iterator = filelist.iterator();
while (iterator.hasNext()) {
SFTPv3DirectoryEntry dirEntry = (SFTPv3DirectoryEntry) iterator .next();
if (dirEntry == null) continue;
if (dirEntry.filename.equals(".") || dirEntry.filename.equals("..")) continue;
copyRecursive(sourceFolder + FTPUtils.FILE_SEPARATOR+dirEntry.filename, targetLocation + Const.FILE_SEPARATOR
+ dirEntry.filename, sftpClient,pattern,parentJob);
}
} else if (isFile(sftpClient, sourceFolder))
{
if(getFileWildcard(sourceFolder,pattern))
copyFile(sourceFolder, targetLocation, sftpClient);
}
}
示例4: GetFiles
import com.trilead.ssh2.SFTPv3Client; //导入方法依赖的package包/类
/**
* copy a directory from the remote host to the local one.
*
* @param sourceLocation
* the source directory on the remote host
* @param targetLocation
* the target directory on the local host
* @param sftpClient
* is an instance of SFTPv3Client that makes SFTP client connection over SSH-2
* @return the number of files successfully copied
* @throws Exception
*/
@SuppressWarnings( "unchecked" )
private void GetFiles( String sourceLocation, String targetLocation, SFTPv3Client sftpClient, Pattern pattern,
Job parentJob ) throws Exception {
String sourceFolder = ".";
if ( !Utils.isEmpty( sourceLocation ) ) {
sourceFolder = sourceLocation + FTPUtils.FILE_SEPARATOR;
} else {
sourceFolder += FTPUtils.FILE_SEPARATOR;
}
Vector<SFTPv3DirectoryEntry> filelist = sftpClient.ls( sourceFolder );
if ( filelist != null ) {
Iterator<SFTPv3DirectoryEntry> iterator = filelist.iterator();
while ( iterator.hasNext() && !parentJob.isStopped() ) {
SFTPv3DirectoryEntry dirEntry = iterator.next();
if ( dirEntry == null ) {
continue;
}
if ( dirEntry.filename.equals( "." )
|| dirEntry.filename.equals( ".." ) || isDirectory( sftpClient, sourceFolder + dirEntry.filename ) ) {
continue;
}
if ( getFileWildcard( dirEntry.filename, pattern ) ) {
// Copy file from remote host
copyFile(
sourceFolder + dirEntry.filename, targetLocation + FTPUtils.FILE_SEPARATOR + dirEntry.filename,
sftpClient );
}
}
}
}
示例5: copyRecursive
import com.trilead.ssh2.SFTPv3Client; //导入方法依赖的package包/类
/**
* copy a directory from the remote host to the local one recursivly.
*
* @param sourceLocation
* the source directory on the remote host
* @param targetLocation
* the target directory on the local host
* @param sftpClient
* is an instance of SFTPv3Client that makes SFTP client connection over SSH-2
* @return the number of files successfully copied
* @throws Exception
*/
private void copyRecursive( String sourceLocation, String targetLocation, SFTPv3Client sftpClient,
Pattern pattern, Job parentJob ) throws Exception {
String sourceFolder = "." + FTPUtils.FILE_SEPARATOR;
if ( sourceLocation != null ) {
sourceFolder = sourceLocation;
}
if ( this.isDirectory( sftpClient, sourceFolder ) ) {
Vector<?> filelist = sftpClient.ls( sourceFolder );
Iterator<?> iterator = filelist.iterator();
while ( iterator.hasNext() ) {
SFTPv3DirectoryEntry dirEntry = (SFTPv3DirectoryEntry) iterator.next();
if ( dirEntry == null ) {
continue;
}
if ( dirEntry.filename.equals( "." ) || dirEntry.filename.equals( ".." ) ) {
continue;
}
copyRecursive( sourceFolder + FTPUtils.FILE_SEPARATOR + dirEntry.filename, targetLocation
+ Const.FILE_SEPARATOR + dirEntry.filename, sftpClient, pattern, parentJob );
}
} else if ( isFile( sftpClient, sourceFolder ) ) {
if ( getFileWildcard( sourceFolder, pattern ) ) {
copyFile( sourceFolder, targetLocation, sftpClient );
}
}
}