469,304 Members | 1,796 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

How to access shared folder if it asks username password

Can you please help me on this I can access one shared folder (folder is in another mahine) from my machine using java program. But From another server machine while accessing the same folder it asks username & password. How can I access it using program. Please reply as soon as possible.

Thanks
Dec 31 '07 #1
3 13522
chaarmann
785 Expert 512MB
Can you please help me on this I can access one shared folder (folder is in another mahine) from my machine using java program. But From another server machine while accessing the same folder it asks username & password. How can I access it using program. Please reply as soon as possible.

Thanks
Enable FTP-access to this folder. FTP is the best protocol for file access.
Then simply use "ftp://username:password@servername/filepath/filename" as URL in your function that opens the file.
Dec 31 '07 #2
Enable FTP-access to this folder. FTP is the best protocol for file access.
Then simply use "ftp://username:password@servername/filepath/filename" as URL in your function that opens the file.
I used this URL. But it is taking as ftp:\username:password@servername\filepath\filenam e. And giving filenot found exception. saying incorrect path of folder/filename. please reply.
Dec 31 '07 #3
chaarmann
785 Expert 512MB
I used this URL. But it is taking as ftp:\username:password@servername\filepath\filenam e. And giving filenot found exception. saying incorrect path of folder/filename. please reply.
If it is taken as that, then you have used the wrong constructor.
read the JDK API about class File, you will see these 2 posbilities:
1.) File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname.

2.) File(URI uri)
Creates a new File instance by converting the given file: URI into an abstract pathname.


you should use the second one, of course, as I wrote "URL" before, and URI is part of URL.

here is an explanation of the difference, quoted from the JDK 1.3 API:
For Microsoft Windows platforms, the prefix of a pathname that contains a drive specifier consists of the drive letter followed by ":" and possibly followed by "\" if the pathname is absolute. The prefix of a UNC pathname is "\\"; the hostname and the share name are the first two names in the name sequence. A relative pathname that does not specify a drive has no prefix.
Jan 1 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

17 posts views Thread by rdemyan via AccessMonster.com | last post: by
7 posts views Thread by Speech Lover | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.