• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SFTPv3Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.trilead.ssh2.SFTPv3Client的典型用法代码示例。如果您正苦于以下问题:Java SFTPv3Client类的具体用法?Java SFTPv3Client怎么用?Java SFTPv3Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SFTPv3Client类属于com.trilead.ssh2包,在下文中一共展示了SFTPv3Client类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sshFileExists

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Check existence of a file
 * 
 * @param sftpClient
 * @param filename
 * @return true, if file exists
 * @throws Exception
 */
public boolean sshFileExists(SFTPv3Client sftpClient, String filename) {
    
    try {
        SFTPv3FileAttributes attributes = sftpClient.stat(filename);
        
        if (attributes != null) {
            return (attributes.isRegularFile());
        } else {
            return false;
        }
        
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:JobEntrySSH2GET.java


示例2: CreateRemoteFolder

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Create remote folder
 * 
 * @param sftpClient
 * @param foldername
 * @return true, if foldername is created
 */
private boolean CreateRemoteFolder(SFTPv3Client sftpClient, String foldername)
{
	LogWriter log = LogWriter.getInstance();
	boolean retval=false;
	
	if(!sshDirectoryExists(sftpClient, foldername))
	{
		try
		{
			sftpClient.mkdir(foldername, 0700);
			retval=true;
			if(log.isDetailed()) log.logDetailed(toString(), Messages.getString("JobSSH2GET.Log.RemoteFolderCreated",foldername));
			
		}catch (Exception e)
		{
			log.logError(toString(), Messages.getString("JobSSH2GET.Log.Error.CreatingRemoteFolder",foldername));
		}
	}
	return retval;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:28,代码来源:JobEntrySSH2GET.java


示例3: sshFileExists

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
* Check existence of a file
* 
* @param sftpClient
* @param filename
* @return true, if file exists
* @throws Exception
*/
  public boolean sshFileExists(SFTPv3Client sftpClient, String filename) {
      
      try {
          SFTPv3FileAttributes attributes = sftpClient.stat(filename);
          
          if (attributes != null) {
              return (attributes.isRegularFile());
          } else {
              return false;
          }
          
      } catch (Exception e) {
          return false;
      }
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:JobEntrySSH2PUT.java


示例4: CreateRemoteFolder

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Create remote folder
 * 
 * @param sftpClient
 * @param foldername
 * @return true, if foldername is created
 */
private boolean CreateRemoteFolder(SFTPv3Client sftpClient, String foldername)
{
	LogWriter log = LogWriter.getInstance();
	boolean retval=false;
	
	if(!sshDirectoryExists(sftpClient, foldername))
	{
		try
		{
			sftpClient.mkdir(foldername, 0700);
			retval=true;
			
		}catch (Exception e)
		{
			log.logError(toString(), Messages.getString("JobSSH2PUT.Log.Error.CreatingRemoteFolder",foldername));
		}
	}
	return retval;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:27,代码来源:JobEntrySSH2PUT.java


示例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);
      }
 }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:35,代码来源:JobEntrySSH2GET.java


示例6: CreateRemoteFolder

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Create remote folder
 * 
 * @param sftpClient
 * @param foldername
 * @return true, if foldername is created
 */
private boolean CreateRemoteFolder(SFTPv3Client sftpClient, String foldername)
{
	boolean retval=false;
	
	if(!sshDirectoryExists(sftpClient, foldername))
	{
		try
		{
			sftpClient.mkdir(foldername, 0700);
			retval=true;
			if(log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2GET.Log.RemoteFolderCreated",foldername));
			
		}catch (Exception e)
		{
			logError(BaseMessages.getString(PKG, "JobSSH2GET.Log.Error.CreatingRemoteFolder",foldername));
		}
	}
	return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:27,代码来源:JobEntrySSH2GET.java


示例7: CreateRemoteFolder

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Create remote folder
 * 
 * @param sftpClient
 * @param foldername
 * @return true, if foldername is created
 */
private boolean CreateRemoteFolder(SFTPv3Client sftpClient, String foldername)
{
	boolean retval=false;
	
	if(!sshDirectoryExists(sftpClient, foldername))
	{
		try
		{
			sftpClient.mkdir(foldername, 0700);
			retval=true;
			
		}catch (Exception e)
		{
			logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Error.CreatingRemoteFolder",foldername));
		}
	}
	return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:26,代码来源:JobEntrySSH2PUT.java


示例8: sshDirectoryExists

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Checks if a directory exists
 * 
 * @param sftpClient
 * @param directory
 * @return true, if directory exists
 */
public boolean sshDirectoryExists(SFTPv3Client sftpClient, String directory)  {
try {
       SFTPv3FileAttributes attributes = sftpClient.stat(directory);
          
        if (attributes != null) {
             return (attributes.isDirectory());
          } else {
              return false;
          }
          
    } catch (Exception e) {
          return false;
    }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:JobEntrySSH2GETDialog.java


示例9: CreateRemoteFolder

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Create remote folder
 * 
 * @param sftpClient
 * @param foldername
 * @return true, if foldername is created
 */
private boolean CreateRemoteFolder(SFTPv3Client sftpClient, String foldername)
{
	boolean retval=false;
	
	if(!sshDirectoryExists(sftpClient, foldername))
	{
		try
		{
			sftpClient.mkdir(foldername, 0700);
			retval=true;
			if(log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "JobSSH2GET.Log.RemoteFolderCreated",foldername));
			
		}catch (Exception e)
		{
			logError(BaseMessages.getString(PKG, "JobSSH2GET.Log.Error.CreatingRemoteFolder",foldername), e);
		}
	}
	return retval;
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:27,代码来源:JobEntrySSH2GET.java


示例10: CreateRemoteFolder

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Create remote folder
 * 
 * @param sftpClient
 * @param foldername
 * @return true, if foldername is created
 */
private boolean CreateRemoteFolder(SFTPv3Client sftpClient, String foldername)
{
	boolean retval=false;
	
	if(!sshDirectoryExists(sftpClient, foldername))
	{
		try
		{
			sftpClient.mkdir(foldername, 0700);
			retval=true;
			
		}catch (Exception e)
		{
			logError(BaseMessages.getString(PKG, "JobSSH2PUT.Log.Error.CreatingRemoteFolder",foldername), e);
		}
	}
	return retval;
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:26,代码来源:JobEntrySSH2PUT.java


示例11: sshFileExists

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Check existence of a file
 *
 * @param sftpClient
 * @param filename
 * @return true, if file exists
 * @throws Exception
 */
public boolean sshFileExists( SFTPv3Client sftpClient, String filename ) {

  try {
    SFTPv3FileAttributes attributes = sftpClient.stat( filename );

    if ( attributes != null ) {
      return ( attributes.isRegularFile() );
    } else {
      return false;
    }

  } catch ( Exception e ) {
    return false;
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:24,代码来源:JobEntrySSH2GET.java


示例12: CreateRemoteFolder

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Create remote folder
 *
 * @param sftpClient
 * @param foldername
 * @return true, if foldername is created
 */
private boolean CreateRemoteFolder( SFTPv3Client sftpClient, String foldername ) {
  boolean retval = false;

  if ( !sshDirectoryExists( sftpClient, foldername ) ) {
    try {
      sftpClient.mkdir( foldername, 0700 );
      retval = true;
      if ( log.isDetailed() ) {
        logDetailed( BaseMessages.getString( PKG, "JobSSH2GET.Log.RemoteFolderCreated", foldername ) );
      }

    } catch ( Exception e ) {
      logError( BaseMessages.getString( PKG, "JobSSH2GET.Log.Error.CreatingRemoteFolder", foldername ), e );
    }
  }
  return retval;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:25,代码来源:JobEntrySSH2GET.java


示例13: isDirectory

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Checks if file is a directory
 * 
 * @param sftpClient
 * @param filename
 * @return true, if filename is a directory
 */
public boolean isDirectory(SFTPv3Client sftpClient, String filename)  
{
	try {
		return sftpClient.stat(filename).isDirectory();
	} 
	catch(Exception e)  {}
	return false;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:16,代码来源:JobEntrySSH2GET.java


示例14: 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);
			}
			
		} 
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:46,代码来源:JobEntrySSH2GET.java


示例15: 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);
      }
 }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:36,代码来源:JobEntrySSH2GET.java


示例16: isFile

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Checks if file is a file
 * 
 * @param sftpClient
 * @param filename
 * @return true, if filename is a directory
 */
public boolean isFile(SFTPv3Client sftpClient, String filename)  
{
	try 
	{
		return sftpClient.stat(filename).isRegularFile();
	} 
	catch(Exception e)  {}
	return false;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:17,代码来源:JobEntrySSH2GET.java


示例17: isDirectory

import com.trilead.ssh2.SFTPv3Client; //导入依赖的package包/类
/**
 * Checks if file is a directory
 * 
 * @param sftpClient
 * @param filename
 * @return true, if filename is a directory
 */
public boolean isDirectory(SFTPv3Client sftpClient, String filename)  
{
	try 
	{
		return sftpClient.stat(filename).isDirectory();
	} 
	catch(Exception e)  {}
	return false;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:17,代码来源:JobEntryFTPDelete.java



注:本文中的com.trilead.ssh2.SFTPv3Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClusterListener类代码示例发布时间:2022-05-23
下一篇:
Java Compiler类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap