FTPConnection
public FTPConnection(String hostname,
int port,
int connectionTimeout,
int timeout,
boolean debug)
throws UnknownHostException,
IOException
Creates a new connection to the server.
hostname
- the hostname of the server to connect toport
- the port to connect to(if <=0, use default port)connectionTimeout
- the connection timeout, in millisecondstimeout
- the I/O timeout, in millisecondsdebug
- print debugging information
allocate
public void allocate(long size)
throws IOException
This command may be required by some servers to reserve sufficient
storage to accommodate the new file to be transferred.
It should be immediately followed by a store
or
append
.
size
- the number of bytes of storage to allocate
append
public OutputStream append(String filename)
throws IOException
Returns a stream for uploading a file.
If a file with the same filename already exists on the server, the
content specified will be appended to the existing file.
filename
- the name of the file to save the content as
- an OutputStream to write the file data to
authenticate
public boolean authenticate(String username,
String password)
throws IOException
Authenticate using the specified username and password.
If the username suffices for the server, the password will not be used
and may be null.
username
- the usernamepassword
- the optional password
- true on success, false otherwise
list
public InputStream list(String pathname)
throws IOException
Returns a listing of information about the specified pathname.
If the pathname specifies a directory or other group of files, the
server should transfer a list of files in the specified directory.
If the pathname specifies a file then the server should send current
information on the file. A null argument implies the user's
current working or default directory.
pathname
- the context pathname, or null
logout
public void logout()
throws IOException
Terminates the control connection.
The file transfer connection remains open for result response only.
This connection is invalid and no further commands may be issued.
nameList
public List nameList(String pathname)
throws IOException
Returns a directory listing. The pathname should specify a
directory or other system-specific file group descriptor; a null
argument implies the user's current working or default directory.
pathname
- the directory pathname, or null
- a list of filenames(strings)
starttls
public boolean starttls(boolean confidential)
throws IOException
Negotiates TLS over the current connection.
See IETF draft-murray-auth-ftp-ssl-15.txt for details.
confidential
- whether to provide confidentiality for the
connection
starttls
public boolean starttls(boolean confidential,
TrustManager tm)
throws IOException
Negotiates TLS over the current connection.
See IETF draft-murray-auth-ftp-ssl-15.txt for details.
confidential
- whether to provide confidentiality for the
connectiontm
- the trust manager used to validate the server certificate.
store
public OutputStream store(String filename)
throws IOException
Returns a stream for uploading a file.
If a file with the same filename already exists on the server, it will
be overwritten.
filename
- the name of the file to save the content as
- an OutputStream to write the file data to
FTPConnection.java --
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.