person_add

Using JSch with Spring Boot, to check if a remote file exists ?

Development : File Spring Spring Boot

Posted by Tobirama 3 years ago



  • Tobirama 3 years ago

    The seven.

     

    private static boolean exists(ChannelSftp channelSftp, String path) { Vector res = null; try { res = channelSftp.ls(path); } catch (SftpException e) { if (e.id == SSH_FX_NO_SUCH_FILE) { return false; } log.error("Unexpected exception during ls files on sftp: [{}:{}]", e.id, e.getMessage()); } return res != null && !res.isEmpty(); }


    Reply


Your answer!



Similars contributions