有什么方法可以使用此 API 过滤要列出的文件吗?例如:
ChannelSftp sftpChannel;
sftpChannel.ls(path);
这列出了所有内容,但我想过滤以 AAA 开头的文件
最佳答案
假设您使用 JSch ,您应该能够在 path
的最后部分使用全局字符(*
和 ?
)。至少this unofficial JavaDoc提到这一点:
The pattern can contain glob pattern wildcards (
*
or?
) in the last component (i.e. after the last/
).
所以尝试一下
sftpChannel.ls(path + '/AAA*');
关于java - ls 过滤 channel ftp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15548135/