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