|
|||||||||
| Home >> All >> org >> apache >> commons >> net >> [ ftp overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.commons.net.ftp
Interface FTPFileEntryParser

- All Known Implementing Classes:
- FTPFileEntryParserImpl
- public interface FTPFileEntryParser
FTPFileEntryParser defines the interface for parsing a single FTP file listing and converting that information into an FTPFile instance. Sometimes you will want to parse unusual listing formats, in which case you would create your own implementation of FTPFileEntryParser and if necessary, subclass FTPFile.
Here are some examples showing how to use one of the classes that implement this interface.
The first example shows how to get an iterable list of files in which the
more expensive FTPFile objects are not created until needed. This
is suitable for paged displays. It requires that a parser object be created
beforehand: parser is an object (in the package
org.apache.commons.net.ftp.parser)
implementing this inteface.
FTPClient f=FTPClient();
f.connect(server);
f.login(username, password);
FTPFileList list = f.createFileList(directory, parser);
FTPFileIterator iter = list.iterator();
while (iter.hasNext()) {
FTPFile[] files = iter.getNext(25); // "page size" you want
//do whatever you want with these files, display them, etc.
//expensive FTPFile objects not created until needed.
}
The second example uses the revised FTPClient.listFiles()
API to pull the whole list from the subfolder subfolder in
one call, attempting to automatically detect the parser type. This
method, without a parserKey parameter, indicates that autodection should
be used.
FTPClient f=FTPClient();
f.connect(server);
f.login(username, password);
FTPFile[] files = f.listFiles("subfolder");
The third example uses the revised FTPClient.listFiles()>
API to pull the whole list from the current working directory in one call,
but specifying by classname the parser to be used. For this particular
parser class, this approach is necessary since there is no way to
autodetect this server type.
FTPClient f=FTPClient();
f.connect(server);
f.login(username, password);
FTPFile[] files = f.listFiles(
"org.apache.commons.net.ftp.parser.EnterpriseUnixFTPFileEntryParser",
".");
The fourth example uses the revised FTPClient.listFiles()
API to pull a single file listing in an arbitrary directory in one call,
specifying by KEY the parser to be used, in this case, VMS.
FTPClient f=FTPClient();
f.connect(server);
f.login(username, password);
FTPFile[] files = f.listFiles("VMS", "subfolder/foo.java");
- Version:
- $Id: FTPFileEntryParser.java 165675 2005-05-02 20:09:55Z rwinston $
| Method Summary | |
FTPFile |
parseFTPEntry(java.lang.String listEntry)
Parses a line of an FTP server file listing and converts it into a usable format in the form of an FTPFile instance. |
java.util.List |
preParse(java.util.List original)
This method is a hook for those implementors (such as VMSVersioningFTPEntryParser, and possibly others) which need to perform some action upon the FTPFileList after it has been created from the server stream, but before any clients see the list. |
java.lang.String |
readNextEntry(java.io.BufferedReader reader)
Reads the next entry using the supplied BufferedReader object up to whatever delemits one entry from the next. |
| Method Detail |
parseFTPEntry
public FTPFile parseFTPEntry(java.lang.String listEntry)
- Parses a line of an FTP server file listing and converts it into a usable
format in the form of an
FTPFileinstance. If the file listing line doesn't describe a file,nullshould be returned, otherwise aFTPFileinstance representing the files in the directory is returned.
readNextEntry
public java.lang.String readNextEntry(java.io.BufferedReader reader) throws java.io.IOException
- Reads the next entry using the supplied BufferedReader object up to
whatever delemits one entry from the next. Implementors must define
this for the particular ftp system being parsed. In many but not all
cases, this can be defined simply by calling BufferedReader.readLine().
preParse
public java.util.List preParse(java.util.List original)
- This method is a hook for those implementors (such as
VMSVersioningFTPEntryParser, and possibly others) which need to
perform some action upon the FTPFileList after it has been created
from the server stream, but before any clients see the list.
The default implementation can be a no-op.
|
|||||||||
| Home >> All >> org >> apache >> commons >> net >> [ ftp overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC