當前位置: 首頁>>代碼示例>>Java>>正文


Java ChannelSftp.rmdir方法代碼示例

本文整理匯總了Java中com.jcraft.jsch.ChannelSftp.rmdir方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelSftp.rmdir方法的具體用法?Java ChannelSftp.rmdir怎麽用?Java ChannelSftp.rmdir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jcraft.jsch.ChannelSftp的用法示例。


在下文中一共展示了ChannelSftp.rmdir方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: delete

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
private void delete(String path, ChannelSftp c) throws Exception {
	String sessionLocalPath = extractSessionPath(path);
	try {
		if (c.stat(sessionLocalPath).isDir())
		{
			List<FileEntry> contents = listFiles(path, c);
			for (FileEntry fe: contents)
			{
				delete(fe.path, c);
			}
			c.rmdir(sessionLocalPath);
		}
		else
		{
			c.rm(sessionLocalPath);
		}
	} catch (Exception e) {
		tryDisconnect(c);
		throw convertException(e);
	}
	
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:23,代碼來源:SftpStorage.java

示例2: delete

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
@Override
public boolean delete(Path path) throws IOException {
  ChannelSftp channel = null;
  try {
    channel = fsHelper.getSftpChannel();
    if (getFileStatus(path).isDir()) {
      channel.rmdir(path.toString());
    } else {
      channel.rm(path.toString());
    }
  } catch (SftpException e) {
    throw new IOException(e);
  } finally {
    safeDisconnect(channel);
  }
  return true;
}
 
開發者ID:Hanmourang,項目名稱:Gobblin,代碼行數:18,代碼來源:SftpLightWeightFileSystem.java

示例3: recursiveDelete

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
private static void recursiveDelete(ChannelSftp sftp, String path)
		throws SftpException, JSchException {
	Vector<?> entries = sftp.ls(path);
	for (Object object : entries) {
		LsEntry entry = (LsEntry) object;
		if (entry.getFilename().equals(".")
				|| entry.getFilename().equals("..")) {
			continue;
		}
		if (entry.getAttrs().isDir()) {
			recursiveDelete(sftp, path + entry.getFilename() + "/");
		} else {
			sftp.rm(path + entry.getFilename());
		}
	}
	sftp.rmdir(path);
}
 
開發者ID:apache,項目名稱:incubator-taverna-common-activities,代碼行數:18,代碼來源:SshToolInvocation.java

示例4: traverse

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
/**
 * Delete directory and its content recursively.
 * 
 * @param channel
 *            open channel to SFTP server
 * @param path
 *            path of the directory
 * @throws SftpException
 *             when something went wrong
 */
@SuppressWarnings("unchecked")
private void traverse(ChannelSftp channel, String path)
        throws SftpException {
    SftpATTRS attrs = channel.stat(path);
    if (attrs.isDir()) {
        Vector<LsEntry> files = channel.ls(path);
        if (files != null && files.size() > 0) {
            Iterator<LsEntry> it = files.iterator();
            while (it.hasNext()) {
                LsEntry entry = it.next();
                if ((!entry.getFilename().equals(".")) && (!entry.getFilename().equals(".."))) {
                    traverse(channel, path + "/" + entry.getFilename());
                }
            }
        }
        channel.rmdir(path);
    } else {
        channel.rm(path);
    }
}
 
開發者ID:psnc-dl,項目名稱:darceo,代碼行數:31,代碼來源:SftpDataStorageClient.java

示例5: delDir

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
/**
  * 刪除指定目錄,此目錄必須為空的目錄
  * @param directory
  * @return boolean
  */
 public  boolean delDir(String directory) {
	boolean flag=false;
	ChannelSftp channel=getChannel();
	try {
		channel.rmdir(directory);
		log.info("刪除目錄:"+directory+"成功");
		flag=true;
	} catch (SftpException e) {
		log.error("刪除目錄:"+directory+"失敗");
		log.error(e.getMessage());
	}finally {
	//channel.quit();            
     }
	
	return flag;
}
 
開發者ID:sapientTest,項目名稱:Sapient,代碼行數:22,代碼來源:SftpFileUtil.java

示例6: doDelete

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
/**
 * Deletes the file.
 */
@Override
protected void doDelete() throws Exception
{
    final ChannelSftp channel = fileSystem.getChannel();
    try
    {
        if (getType() == FileType.FILE)
        {
            channel.rm(relPath);
        }
        else
        {
            channel.rmdir(relPath);
        }
    }
    finally
    {
        fileSystem.putChannel(channel);
    }
}
 
開發者ID:wso2,項目名稱:wso2-commons-vfs,代碼行數:24,代碼來源:SftpFileObject.java

示例7: delete

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
@Override
public boolean delete(Path path) throws IOException {
  ChannelSftp channel = null;
  try {
    channel = this.fsHelper.getSftpChannel();
    if (getFileStatus(path).isDirectory()) {
      channel.rmdir(HadoopUtils.toUriPath(path));
    } else {
      channel.rm(HadoopUtils.toUriPath(path));
    }
  } catch (SftpException e) {
    throw new IOException(e);
  } finally {
    safeDisconnect(channel);
  }
  return true;
}
 
開發者ID:apache,項目名稱:incubator-gobblin,代碼行數:18,代碼來源:SftpLightWeightFileSystem.java

示例8: execute

import com.jcraft.jsch.ChannelSftp; //導入方法依賴的package包/類
@Override
protected void execute() throws SftpResult, JSchException {
    ChannelSftp ch = channel();
    try {
        ch.rmdir(path);
        throw new SftpResult(true);
    } catch (SftpException e) {
        if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
            throw new SftpResult(false);
        }
        throw new SftpError(e, "Error putting file[%s]", path);
    } finally {
        release(ch);
    }
}
 
開發者ID:osglworks,項目名稱:java-sftp,代碼行數:16,代碼來源:DeleteDir.java


注:本文中的com.jcraft.jsch.ChannelSftp.rmdir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。