本文整理汇总了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);
}
}
示例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();
}
}
示例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();
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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());
}
}
示例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);
}