当前位置: 首页>>代码示例>>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;未经允许,请勿转载。