/** * List files in the specified directory, apply a filter then pass each one to a consumer * <p> * @param pathname directory name * @param filter filter * @param c Consumer * <p> * @throws IOException */ default void forEach( String pathname, FTPFileFilter filter, IOConsumer<FTPFile> c ) throws IOException { try { forEachFile( pathname, filter, c.guard() ); } catch( UncheckedIOException ex ) { throw ex.getCause(); } }
default void forEachMlist( String pathname, FTPFileFilter filter, IOConsumer<FTPFile> c ) throws IOException { try { forEachMlistDir( pathname, filter, c.guard() ); } catch( UncheckedIOException ex ) { throw ex.getCause(); } }
public FTPFile[] getFiles(FTPFileFilter filter) throws IOException { ArrayList tmpResults = new ArrayList(); Iterator iter = this.entries.iterator(); while(iter.hasNext()) { String entry = (String)iter.next(); FTPFile temp = this.parser.parseFTPEntry(entry); if(filter.accept(temp)) { tmpResults.add(temp); } } return (FTPFile[])tmpResults.toArray(new FTPFile[tmpResults.size()]); }
public FTPFile[] listFiles(final String pathname, final FTPFileFilter filter) throws IOException { if (pathname == null || filter == null) { return null; } // return execute(new FtpClientCallback<FTPFile[]>() { public FTPFile[] doInAction(FtpClientSession session) throws FtpClientTemplateException { try { return session.listFiles(pathname, filter); } catch (Exception ex) { throw new FtpClientTemplateException(ex); } } }); }
public FTPFile[] listFiles(String pathname, FTPFileFilter filter) { try { return ftpClientTemplate.listFiles(pathname, filter); } catch (Exception ex) { throw new CommonFtoException(ex); } }
@Override public Collection<FTPFile> mlistDir( String pathname, FTPFileFilter filter ) throws IOException { return Arrays.asList( ftp.mlistDir( pathname, filter ) ); }
@Override public Collection<FTPFile> listFiles( String pathname, FTPFileFilter filter ) throws IOException { return Arrays.asList( ftp.listFiles( pathname, filter ) ); }
default Stream<FTPFile> files( String pathname, FTPFileFilter filter ) throws IOException { return listFiles( pathname, filter ).stream(); }
default Stream<FTPFile> files( FTPFileFilter filter ) throws IOException { return listFiles( filter ).stream(); }
Collection<FTPFile> mlistDir( String pathname, FTPFileFilter filter ) throws IOException;
default void forEachMlistDir( String pathname, FTPFileFilter filter, Consumer<FTPFile> c ) throws IOException { CollectionUtils.forEach( mlistDir( pathname, filter ), c ); }
@Override public Collection<FTPFile> listFiles( String pathname, FTPFileFilter filter ) throws IOException { return getClient().listFiles( pathname, filter ); }
@Override public Stream<FTPFile> files( String pathname, FTPFileFilter filter ) throws IOException { return getClient().files( pathname, filter ); }
@Override public Collection<FTPFile> listFiles( FTPFileFilter filter ) throws IOException { return getClient().listFiles( filter ); }
@Override public Stream<FTPFile> files( FTPFileFilter filter ) throws IOException { return getClient().files( filter ); }
@Override public void forEachFile( String pathname, FTPFileFilter filter, Consumer<FTPFile> c ) throws IOException { getClient().forEachFile( pathname, filter, c ); }
@Override public void forEach( FTPFileFilter filter, IOConsumer<FTPFile> c ) throws IOException { getClient().forEach( filter, c ); }
@Override public void forEach( String pathname, FTPFileFilter filter, IOConsumer<FTPFile> c ) throws IOException { getClient().forEach( pathname, filter, c ); }
@Override public Collection<FTPFile> mlistDir( String pathname, FTPFileFilter filter ) throws IOException { return getClient().mlistDir( pathname, filter ); }
@Override public void forEachMlistDir( String pathname, FTPFileFilter filter, Consumer<FTPFile> c ) throws IOException { getClient().forEachMlistDir( pathname, filter, c ); }
@Override public void forEachMlist( String pathname, FTPFileFilter filter, IOConsumer<FTPFile> c ) throws IOException { getClient().forEachMlist( pathname, filter, c ); }
public FTPFile[] mlistDir(String pathname, FTPFileFilter filter) throws IOException { FTPListParseEngine engine = this.initiateMListParsing(pathname); return engine.getFiles(filter); }
public FTPFile[] listFiles(String pathname, FTPFileFilter filter) throws IOException { FTPListParseEngine engine = this.initiateListParsing((String)null, pathname); return engine.getFiles(filter); }
public FTPFile[] mlistDir(String pathname, FTPFileFilter filter) throws IOException { return delegate.mlistDir(pathname, filter); }
public FTPFile[] listFiles(String pathname, FTPFileFilter filter) throws IOException { return delegate.listFiles(pathname, filter); }
public FTPFile[] mlistDir(String pathname, FTPFileFilter filter) throws IOException { return this.delegate.mlistDir(pathname, filter); }
public FTPFile[] listFiles(String pathname, FTPFileFilter filter) throws IOException { checkOpen(); return this.delegate.listFiles(pathname, filter); }
FTPFile[] listFiles(String pathname, FTPFileFilter filter) throws IOException;
/** * 列出指定路径中的文件和文件夹信息(可以是单独的一个文件 ),因为 org.apache.commons.net.ftp.FTPFile 中没有文件路径信息,故重新包装为自定义的 FTPFile 类 * * @param remotePath * @param ftpFileFilter 过滤器 * @return * @throws FtpException */ @Override public List<JFTPFile> listFiles(String remotePath, FTPFileFilter ftpFileFilter) throws FtpException { List<JFTPFile> files = new ArrayList<JFTPFile>(); try { String originalWorkingDirectory = getWorkingDirectory(); if (existsDirectory(remotePath)) changeDirectory(remotePath); else throw new FtpException(String.format(NO_SUCH_DIRECTORY_MESSAGE, remotePath)); String newWorkingDirectory = getWorkingDirectory(); FTPFile[] ftpFiles; if (ftpFileFilter == null) ftpFiles = client.listFiles(newWorkingDirectory); else ftpFiles = client.listFiles(newWorkingDirectory, ftpFileFilter); for (FTPFile file : ftpFiles) files.add(toFtpFile(file, newWorkingDirectory)); //恢复 ftpClient 当前工作目录属性 changeDirectory(originalWorkingDirectory); } catch (IOException e) { throw new FtpException(String.format(FILE_LISTING_ERROR_MESSAGE, remotePath), e); } return files; }
/** * List all files in a directory * <p> * @param pathname directory name * @param filter Filter to use * <p> * @return collection of entries * <p> * @throws IOException */ Collection<FTPFile> listFiles( String pathname, FTPFileFilter filter ) throws IOException;
/** * List all files in a directory * <p> * @param filter Filter to use * <p> * @return collection of entries * <p> * @throws IOException */ default Collection<FTPFile> listFiles( FTPFileFilter filter ) throws IOException { return listFiles( null, filter ); }
/** * List files in the specified directory, apply a filter then pass each one to a consumer * <p> * @param pathname directory name * @param filter filter * @param c Consumer * <p> * @throws IOException */ default void forEachFile( String pathname, FTPFileFilter filter, Consumer<FTPFile> c ) throws IOException { CollectionUtils.forEach( listFiles( pathname, filter ), c ); }