当前位置: 首页>>代码示例>>Java>>正文


Java SftpException.getMessage方法代码示例

本文整理汇总了Java中com.jcraft.jsch.SftpException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SftpException.getMessage方法的具体用法?Java SftpException.getMessage怎么用?Java SftpException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jcraft.jsch.SftpException的用法示例。


在下文中一共展示了SftpException.getMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fastExistsFile

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
protected boolean fastExistsFile(String name) throws GenericFileOperationFailedException {
    LOG.trace("fastExistsFile({})", name);
    try {
        @SuppressWarnings("rawtypes")
        Vector files = channel.ls(name);
        if (files == null) {
            return false;
        }
        return files.size() >= 1;
    } catch (SftpException e) {
        // or an exception can be thrown with id 2 which means file does not exists
        if (ChannelSftp.SSH_FX_NO_SUCH_FILE == e.id) {
            return false;
        }
        // otherwise its a more serious error so rethrow
        throw new GenericFileOperationFailedException(e.getMessage(), e);
    }

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:SftpOperations.java

示例2: mkdir

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
public synchronized boolean mkdir(String remoteFile) throws SFTPConnectionException {
	checkLocked();
	this.checkConnection();
	try {
		File f = new File(remoteFile);

		this.changeWorkingDirectory(AbstractRemoteFileSystemDriver.normalizeIfNeeded(f.getParent()));
		this.updateOpTime();
		debug("mkdir : mkdir", remoteFile);
		client.mkdir(encodeRemoteFile(f.getName()));
		FictiveFile existing = this.fileInfoCache.getCachedFileInfos(remoteFile);
		if (existing != null) {
			existing.init(0, true, true, 0);
		} else {
			this.fileInfoCache.registerFileInfo(remoteFile, new FictiveFile(remoteFile, remoteFile, 0, true, true, 0));
		}
		return true;
	} catch (SftpException e) {
		removeCachedFileInfos(remoteFile);
		resetClient(e);
		throw new SFTPConnectionException(e.getMessage());
	} finally {
		resetContextData();
	}
}
 
开发者ID:chfoo,项目名称:areca-backup-release-mirror,代码行数:26,代码来源:SFTPProxy.java

示例3: renameTo

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
public synchronized boolean renameTo(String source, String destination) throws SFTPConnectionException {
	checkLocked();
	this.checkConnection();

	try {
		debug("renameTo : rename", source + "->" + destination);
		client.rename(encodeRemoteFile(source), encodeRemoteFile(destination));
		this.updateOpTime();
		return true;
	} catch (SftpException e) {
		resetClient(e);
		throw new SFTPConnectionException(e.getMessage());
	} finally {
		resetContextData();

		FictiveFile file = fileInfoCache.getCachedFileInfos(destination);
		if (file != null && file.exists() && file.isFile()) {
			// Case 1 : "source" is a file -> selectively remove the entries from the cache
			removeCachedFileInfos(source);
			removeCachedFileInfos(destination);
		} else {
			// Case 2 : We don't know whether "source" is a file or a directory -> destroy all the cache
			clearCache();
		}
	}
}
 
开发者ID:chfoo,项目名称:areca-backup-release-mirror,代码行数:27,代码来源:SFTPProxy.java

示例4: getFileOutputStream

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
public synchronized OutputStream getFileOutputStream(final String file, boolean append) throws RemoteConnectionException {
	if (append) {
		throw new UnsupportedOperationException("Append mode not supported on the SFTP implementation.");
	}

	checkLocked();
	this.checkConnection();
	OutputStream result = null;
	try {
		debug("getFileOutputStream : put", file);
		result = client.put(encodeRemoteFile(file), ChannelSftp.OVERWRITE);

		this.updateOpTime();
		return new RemoteFileOutputStream(this, result, ownerId, file);
	} catch (SftpException e) {
		resetClient(e);
		throw new SFTPConnectionException(e.getMessage());
	}  finally {
		removeCachedFileInfos(file);
	}
}
 
开发者ID:chfoo,项目名称:areca-backup-release-mirror,代码行数:22,代码来源:SFTPProxy.java

示例5: convertException

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
private Exception convertException(Exception e) {

		if (SftpException.class.isAssignableFrom(e.getClass()) )
		{
			SftpException sftpEx = (SftpException)e;
			if (sftpEx.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
				return new FileNotFoundException(sftpEx.getMessage());
		}
		
		return e;

	}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:13,代码来源:SftpStorage.java

示例6: existsFile

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
public synchronized boolean existsFile(String name) throws GenericFileOperationFailedException {
    LOG.trace("existsFile({})", name);
    if (endpoint.isFastExistsCheck()) {
        return fastExistsFile(name);
    }
    // check whether a file already exists
    String directory = FileUtil.onlyPath(name);
    if (directory == null) {
        // assume current dir if no path could be extracted
        directory = ".";
    }
    String onlyName = FileUtil.stripPath(name);

    try {
        @SuppressWarnings("rawtypes")
        Vector files = channel.ls(directory);
        // can return either null or an empty list depending on FTP servers
        if (files == null) {
            return false;
        }
        for (Object file : files) {
            ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) file;
            String existing = entry.getFilename();
            LOG.trace("Existing file: {}, target file: {}", existing, name);
            existing = FileUtil.stripPath(existing);
            if (existing != null && existing.equals(onlyName)) {
                return true;
            }
        }
        return false;
    } catch (SftpException e) {
        // or an exception can be thrown with id 2 which means file does not exists
        if (ChannelSftp.SSH_FX_NO_SUCH_FILE == e.id) {
            return false;
        }
        // otherwise its a more serious error so rethrow
        throw new GenericFileOperationFailedException(e.getMessage(), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:40,代码来源:SftpOperations.java

示例7: getFileStream

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
/**
 * Executes a get SftpCommand and returns an input stream to the file
 * @param cmd is the command to execute
 * @param sftp is the channel to execute the command on
 * @throws SftpException
 */
public InputStream getFileStream(String file)
    throws FileBasedHelperException {
  SftpGetMonitor monitor = new SftpGetMonitor();
  try {
    return getSftpChannel().get(file, monitor);
  } catch (SftpException e) {
    throw new FileBasedHelperException("Cannot download file " + file + " due to " + e.getMessage(), e);
  }
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:16,代码来源:SftpFsHelper.java

示例8: getFileInputStream

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
public synchronized InputStream getFileInputStream(String file) throws SFTPConnectionException {
	checkLocked();
	this.checkConnection();
	try {
		debug("getFileInputStream : retrieveFileStream", file);
		InputStream result = this.client.get(encodeRemoteFile(file));

		this.updateOpTime();
		return new RemoteFileInputStream(this, result, ownerId);
	} catch (SftpException e) {
		resetClient(e);
		throw new SFTPConnectionException(e.getMessage());
	}
}
 
开发者ID:chfoo,项目名称:areca-backup-release-mirror,代码行数:15,代码来源:SFTPProxy.java

示例9: decorateSftpException

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
private static SftpIOException decorateSftpException(SftpException e, String path) {
    return new SftpIOException(e.id, e.getMessage(), path, e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:SftpSupport.java


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