/** * Checks if a directory exists * * @param sftpClient * @param directory * @return true, if directory exists */ public boolean sshDirectoryExists(SFTPv3Client sftpClient, String directory) { try { SFTPv3FileAttributes attributes = sftpClient.stat(directory); if (attributes != null) { return (attributes.isDirectory()); } else { return false; } } catch (Exception e) { return false; } }
/** * Check existence of a file * * @param sftpClient * @param filename * @return true, if file exists * @throws Exception */ public boolean sshFileExists(SFTPv3Client sftpClient, String filename) { try { SFTPv3FileAttributes attributes = sftpClient.stat(filename); if (attributes != null) { return (attributes.isRegularFile()); } else { return false; } } catch (Exception e) { return false; } }