The moose likes I/O and Streams and the fly likes FTP password 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 password" Watch "FTP password" New topic

FTP password

Eugene Max

Joined: Oct 11, 2001
Posts: 7
I am creating an application that will upload a local file to an FTP site. The FTP server needs account and password to be accessed. How do I write the password inside the code?
myaccount@ ?mypassword?
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
Generally, it's considered bad practice to put the password directly into the URL string, however, you can do
You can get the username and password out using a which will return you "username:password"
Alternatively, if you use javax.mail.URLName (from JavaMail api) you can do URLName.getUsername(), and URLName.getPassword()

I have no java certifications. This makes me a bad programmer. Ignore my post.
Eugene Max

Joined: Oct 11, 2001
Posts: 7
Thanks alot... It's a big help...
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 614
Hi,Eugene Max
Can you tell me how are you uploading the file using FTP in java.
I have to do exactly the same thing in my module.

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