使用JSch,有没有一种方法可以在不执行ls的情况下判断是否存在远程文件? [英] Using JSch, is there a way to tell if a remote file exists without doing an ls?

查看:113
本文介绍了使用JSch,有没有一种方法可以在不执行ls的情况下判断是否存在远程文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JSch,有没有办法在不执行ls并循环浏览文件以查找名称匹配的情况下,确定是否存在远程文件?

Using JSch, is there a way to tell if a remote file exists without doing an ls and looping through the files to find a name match?

谢谢

推荐答案

(这是如果您使用的是库的SFTP部分,这是我没有考虑的假设.)

我认为它的ls(String path)将接受文件名;我目前无法检查.

I thought its ls(String path) would accept filenames; I can't check at the moment.

如果没有,则无需手动进行迭代;您可以使用选择器变体:

If it doesn't, you don't need to iterate manually; you can use the selector variant:

ls(String path, ChannelSftp.LsEntrySelector selector)

这篇关于使用JSch,有没有一种方法可以在不执行ls的情况下判断是否存在远程文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆