File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes FTP in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "FTP in java" Watch "FTP in java" New topic

FTP in java

Radhika Gokhale
Ranch Hand

Joined: Dec 12, 2002
Posts: 40
I am trying to implement a FTP Loader in java.
Till now I am able to connect to the FTP Server successfully using Sockets.
I am able to pass user, pass and pwd commands to the ftp server using a dataoutputstream object.
Now when I am trying to access the files or directories present at the server I pass the ls command. But this command is not working.
Pls suggest what should I do for this.
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
a) Are you trying to write your own FTP implementation?
Answer :- don't... use someone elses work. If you must then read and understand RFC959 which can be found at
There was a lengthy discussion about sockets (ftp in particular) on the socket and internet protocols forum at javaranch

I have no java certifications. This makes me a bad programmer. Ignore my post.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
hi Radhika,
so you are using someone elses code? if so then you can have look at that code (may by decompile it if you don't have the source code) and then understand how FTP client works by browing Google. that can give u better idea about the problem you face...

if you have implemented on your own then please post your code for the communication with the FTP server so we can throw some thoughts on it and have better idea about it..
i have a FTP client code myself but if you are interested in developing it yourself then i would be happy to guide you if i can...
i also had copied a code from somewhere else but i did following things before i used it,
1. read the code and understood how FTP client works
2. removed a bug in the code that i found when i didnt get output of 'pwd' command...
FTP help might be helpful to you to understand FTP client basics
Radhika Gokhale
Ranch Hand

Joined: Dec 12, 2002
Posts: 40
Hi Maulin Vasavada & Chang
Thanks for your replies.
I am trying to implement this FTP loader which can upload and download files on and from a remote ftp server.
Actually I am new to Java coding. I have somehow managed to connect to the server thru my prog.
Now the problem is that if I give ls or any other command it's not working
Only pwd works

I will post my code on this in a short while.

I agree. Here's the link:
subject: FTP in java
It's not a secret anymore!