/** * * @param path the file PATH * @return true if the file exist */ public boolean existFile(String directory,String fileRegExp) throws IOException { if(!connected) this.connect(); FTPFile[] files = this.ftpClient.listFiles(directory,FTPFileFilters.ALL); if(files == null || files.length == 0) return false; for (int i = 0; i < files.length; i++) { if(!files[i].isFile()) continue; if(files[i].getName().matches(fileRegExp)) return true; } return false; }
@Override protected List<PathAttributes> listDirectory(Path path) throws XenonException { assertIsOpen(); assertDirectoryExists(path); try { ArrayList<PathAttributes> result = new ArrayList<>(); for (FTPFile f : ftpClient.listFiles(path.toString(), FTPFileFilters.NON_NULL)) { result.add(convertAttributes(path.resolve(f.getName()), f)); } return result; } catch (IOException e) { throw new XenonException(ADAPTOR_NAME, "Failed to retrieve directory listing of " + path, e); } }
public FTPFile[] listDirectories(String parent) throws IOException { return this.listFiles(parent, FTPFileFilters.DIRECTORIES); }
public FTPFile[] getFiles() throws IOException { return this.getFiles(FTPFileFilters.NON_NULL); }