aspose file tools*
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
Author

FTP password

Eugene Max
Greenhorn

Joined: Oct 11, 2001
Posts: 7
Hi!
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@ftp://oursite.com ?mypassword?
Thanks,
Eugene
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
ftp://username:password@site.com:port/directory.
You can get the username and password out using a java.net.URL.getUserInfo() 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
Greenhorn

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

Joined: Jun 21, 2001
Posts: 613
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.
thanks,
Trupti

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FTP password