You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by David Johnson <ch...@gmail.com> on 2006/01/09 21:31:07 UTC
Commons/Net Documentation
Hi there
I'm trying to find basic documentation for the Commons/Net package, and both
links that I see here http://jakarta.apache.org/commons/net/ are rather
unhelpful.
What I'm trying to do is fairly straigtforward
1. Connect to a known FTP server
2. Login to said FTP server using known userid and password
3. set the transfer type to ASCII
4. Transfer a file (whose location I have) to a subdirectory (/uploadTest)
5. close the connection
6. do allapproriate error checking.
I dont see that sort of basic information in the JavaDocs..
what I have so far is
FTPClient ftpServer=new FTPClient();
FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
ftpServer.configure(conf);
boolean error = false;
try {
int reply;
ftpServer.connect(commonLocation);
System.out.println("Connected to " + commonLocation + ".");
System.out.print(ftpServer.getReplyString());
reply = ftpServer.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftpServer.disconnect();
System.err.println("Error -- FTP server refused connection.");
}
ftpServer.login(ftpUser, ftpPass);
// Set the transfer type
// Chenge directories
// transfer file
ftpServer.logout();
} catch(IOException e) {
error = true;
e.printStackTrace();
} finally {
if(ftpServer.isConnected()) {
try {
ftpServer.disconnect();
} catch(IOException ioe) {
// do nothing
}
}
}
where can I go to get this info?
--
-Dave
ChaChaNY@Gmail.com
Re: Commons/Net Documentation
Posted by David Johnson <ch...@gmail.com>.
I've made some progress. I can now log into the server... but instead of
transferring the file (C:\builds\wsdl\AmazonWebServices.wsdl), it creates a
0 length file with the name "C:\builds\wsdl\AmazonWebServices.wsdl"
hmmm wth am i missing?
//Code:
ftpServer.user(ftpUser);
ftpServer.pass(ftpUser);
ftpServer.cwd(directory); //testDirectory
ftpServer.stor(wsdlLocation); // wsdlLocation =
"C:\builds\wsdl\AmazonWebServices.wsdl"
Thanks,
Dave
On 1/9/06, David Johnson <ch...@gmail.com> wrote:
>
> Hi there
>
> I'm trying to find basic documentation for the Commons/Net package, and
> both links that I see here http://jakarta.apache.org/commons/net/ are
> rather unhelpful.
>
> What I'm trying to do is fairly straigtforward
>
> 1. Connect to a known FTP server
> 2. Login to said FTP server using known userid and password
> 3. set the transfer type to ASCII
> 4. Transfer a file (whose location I have) to a subdirectory (/uploadTest)
>
> 5. close the connection
> 6. do allapproriate error checking.
>
> I dont see that sort of basic information in the JavaDocs..
>
> what I have so far is
>
> FTPClient ftpServer=new FTPClient();
> FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
> ftpServer.configure(conf);
>
> boolean error = false;
> try {
> int reply;
>
> ftpServer.connect(commonLocation);
> System.out.println("Connected to " + commonLocation + ".");
> System.out.print(ftpServer.getReplyString());
>
> reply = ftpServer.getReplyCode();
>
> if(!FTPReply.isPositiveCompletion(reply)) {
> ftpServer.disconnect();
> System.err.println("Error -- FTP server refused connection.");
> }
>
> ftpServer.login(ftpUser, ftpPass);
> // Set the transfer type
> // Chenge directories
> // transfer file
>
> ftpServer.logout();
> } catch(IOException e) {
> error = true;
> e.printStackTrace();
> } finally {
> if(ftpServer.isConnected()) {
> try {
> ftpServer.disconnect();
> } catch(IOException ioe) {
> // do nothing
> }
> }
> }
>
> where can I go to get this info?
>
> --
> -Dave
> ChaChaNY@Gmail.com
--
-Dave
ChaChaNY@Gmail.com