This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes FTP in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "FTP in Java" Watch "FTP in Java" New topic

FTP in Java

Bhupendra Gupta

Joined: Oct 13, 2009
Posts: 1
Hi team,

I am new to java and an not sure whether this is the right place to ask question about FTP in java..

I have written a small code in java which FTPs to one of the remote server.

The code gives me the list of files that are present on that server but it does not uploads the file there.(code is running successfully though)

here is the code:

Could you please help me out with this
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41150
Welcome to JavaRanch.

In the future, please UseCodeTags when posting code of any length. It's unnecessarily hard to read the code as it is, making it less likely that people will bother to do so. I've done this for you here.

For starters, you're ignoring the return value of "storeFile". That will tell you whether the file upload was successful or not. I'm not sure why you think that "client.changeToParentDirectory()" would tell you whether the upload was successful - it tells you whether changing the directory was successful, which is something entirely different.

Also note that you're using the complete client-side path as filename for the server - including the directories. You should truncate that to just the filename.

I'll move the post to the "Other Open Source Projects" forum, where the Apache libraries are discussed.

Ping & DNS - my free Android networking tools app
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345

Are you using any Apache related API's by the way?

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
I agree. Here's the link:
subject: FTP in Java
Similar Threads
Problem with moving a file from one Directory to other Directory using FTPClient rename Method
Reading log files from various unix servers through Java program on windows
How to upload file to ftp in java
FTP Dowload JPG & XML files only... USing* from FTP server
How to run FTP.exe with/without IP Address, Username and password?