|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.radinks.net.FTPConnection
| Nested Class Summary | |
class |
FTPConnection.DataConnection
Inner class that acts as an abstraction layer for Socket
and ServerSocket. |
| Field Summary | |
static int |
ACTIVE_MODE
|
protected int |
connectMode
flag - defines whether to connect in active or passive modes. |
protected int |
contentLength
|
protected static byte[] |
CRLF
|
protected java.io.InputStream |
in
|
protected java.lang.String |
lastMessage
|
protected java.net.URL |
location
The FTP server that we are connecting to, the username and password that is being used for authentication and the starting location on the folder tree are all defined by this URL. |
protected java.io.OutputStream |
out
|
static int |
PASV_MODE
|
protected java.net.Socket |
sock_control
|
protected java.net.Socket |
sock_data
|
protected int |
timeout
socket timeout |
protected java.lang.String |
welcome
|
protected java.io.Writer |
writer
|
| Constructor Summary | |
FTPConnection()
|
|
FTPConnection(java.lang.String location)
Open a connection to the given FTP URL. |
|
| Method Summary | |
boolean |
cdhome()
Set current working directory to the path defined in the url. |
boolean |
check_reply(java.lang.String code)
Returns true if the server returns the expected code. |
boolean |
chmod(int perms,
java.lang.String path)
Chmod is implemened via the site command. |
boolean |
cwd(java.lang.String dir)
Change Working Directory |
java.io.InputStream |
getIn()
|
java.lang.String |
getLastMessage()
Returns the last response from the server. |
java.net.URL |
getLocation()
|
java.io.PrintStream |
getLogWriter()
|
java.io.OutputStream |
getOut()
|
java.io.Writer |
getWriter()
Returns the writer associated with the control socket. |
void |
initStream()
The server usually sends a 220 reply when your first connect to it. |
boolean |
isOk()
Error messages are typically 500 status codes. |
protected void |
log(java.lang.String mes)
logs the communitcation. |
boolean |
login()
Login, if the location includes a username and password use them,
else login annonymousy. |
boolean |
login(java.lang.String username,
java.lang.String password)
Logs into the system with the given username and password. |
FTPConnection.DataConnection |
makeDataConnection()
open a new active or passive data connection. |
boolean |
mkdir(java.lang.String dir)
Create a new directory on the server, will not attempt to determine if the directory already exists. |
void |
openConnection()
Open the connection to the previously defined URL given in location. |
boolean |
pass(java.lang.String pass)
sends the password as part of the user authentication procedure and reads the welcome message if one is available. |
protected java.net.Socket |
pasv()
Open a passive mode data connection. |
java.net.ServerSocket |
port()
Open a data connection in active mode. |
void |
setLocation(java.net.URL location)
|
void |
setLogWriter(java.io.PrintStream logWriter)
Where to log. |
int |
switchMode()
Swtich between Active and Passive modes. |
boolean |
testConnection()
Are you there? |
boolean |
user(java.lang.String user)
sends the USER command to the server, you can call this method directory if you want more control than given by the login() method. |
protected void |
writeln(java.lang.String s)
Centralize all the write operations for ease of maintenance. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static int ACTIVE_MODE
public static int PASV_MODE
protected int connectMode
protected int timeout
protected static final byte[] CRLF
protected int contentLength
protected java.net.URL location
protected java.io.OutputStream out
protected java.io.Writer writer
protected java.io.InputStream in
protected java.net.Socket sock_control
protected java.net.Socket sock_data
protected java.lang.String welcome
protected java.lang.String lastMessage
| Constructor Detail |
public FTPConnection()
public FTPConnection(java.lang.String location)
throws java.net.MalformedURLException
location - a url on the ftp server.
java.net.MalformedURLException| Method Detail |
public boolean login()
throws java.io.IOException
location includes a username and password use them,
else login annonymousy.
java.io.IOException
public boolean cdhome()
throws java.io.IOException
url.
java.io.IOException
public boolean chmod(int perms,
java.lang.String path)
throws java.io.IOException
perms - the permission to applypath - the file name to apply the permissions to
java.io.IOException
public boolean cwd(java.lang.String dir)
throws java.io.IOException
dir - to change to
java.io.IOException
public boolean login(java.lang.String username,
java.lang.String password)
throws java.io.IOException
username - usernamepassword - password
java.io.IOException
public void openConnection()
throws java.io.IOException,
java.net.UnknownHostException
location.
java.io.IOException
java.net.UnknownHostException
public void initStream()
throws java.io.IOException
java.io.IOException
protected void writeln(java.lang.String s)
throws java.io.IOException
s - the data to be sent over the control connection.
java.io.IOException
public java.net.ServerSocket port()
throws java.io.IOException
java.io.IOException
protected java.net.Socket pasv()
throws java.io.IOException
java.io.IOExceptionpublic java.io.InputStream getIn()
InputStream for the control connection.public java.io.OutputStream getOut()
OutputStream for the control connection.
public boolean isOk()
throws java.io.IOException
java.io.IOException
public boolean check_reply(java.lang.String code)
throws java.io.IOException
code - the status code that we expect.
java.io.IOException
public boolean mkdir(java.lang.String dir)
throws java.io.IOException
dir - - name of the new folder.
java.io.IOException
public boolean user(java.lang.String user)
throws java.io.IOException
login() method.
user - username
java.io.IOException
public boolean pass(java.lang.String pass)
throws java.io.IOException
pass - - password for the user
java.io.IOExceptionprotected void log(java.lang.String mes)
mes - add this message to the log.public java.lang.String getLastMessage()
check_reply() returned false, which
indicates that the expected response was not recieved. The last
message should then be retrieved for closer ispection.
public int switchMode()
public FTPConnection.DataConnection makeDataConnection()
throws java.io.IOException
java.io.IOExceptionpublic void setLogWriter(java.io.PrintStream logWriter)
logWriter - use this writer for loggin.public java.io.PrintStream getLogWriter()
public boolean testConnection()
public java.io.Writer getWriter()
public void setLocation(java.net.URL location)
public java.net.URL getLocation()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Rad Inks FTP library
Copyright (c) 2003,2004 Rad Inks (Pvt) Ltd.