當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。