Using JSch, is there a way to tell if a remote file exists without doing an ls?

前端 未结 6 447
轻奢々
轻奢々 2020-12-15 21:42

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?

Thanks

6条回答
  •  离开以前
    2020-12-15 22:05

    (This is if you're using the SFTP part of the library, an assumption I made without thinking about it.)

    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)
    

提交回复
热议问题