* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
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 uses the
API to pull the whole list from the subfolder
one call, attempting to automatically detect the parser type. This
method, without a parserKey parameter, indicates that autodection should
FTPClient f=FTPClient(); f.connect(server); f.login(username, password); FTPFile files = f.listFiles("subfolder");The secondr example uses the
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 third example uses the
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");For an alternative approach, see the
class which provides iterative access.
FTPFileinstance. If the file listing line doesn't describe a file,
nullshould be returned, otherwise a
FTPFileinstance representing the files in the directory is returned.
listEntryA line of text from the file listing
readerThe BufferedReader object from which entries are to be read.
java.io.IOExceptionthrown on any IO Error reading from the reader.
originalOriginal list after it has been created from the server stream
/* Emacs configuration
* Local variables: **
* mode: java **
* c-basic-offset: 4 **
* indent-tabs-mode: nil **
* End: **