How to access shared folder if it asks username password

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajamohammed
    New Member
    • Jul 2007
    • 11

    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
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Originally posted by rajamohammed
    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:passwo rd@servername/filepath/filename" as URL in your function that opens the file.

    Comment

    • rajamohammed
      New Member
      • Jul 2007
      • 11

      #3
      Originally posted by chaarmann
      Enable FTP-access to this folder. FTP is the best protocol for file access.
      Then simply use "ftp://username:passwo rd@servername/filepath/filename" as URL in your function that opens the file.
      I used this URL. But it is taking as ftp:\username:p assword@servern ame\filepath\fi lename. And giving filenot found exception. saying incorrect path of folder/filename. please reply.

      Comment

      • chaarmann
        Recognized Expert Contributor
        • Nov 2007
        • 785

        #4
        Originally posted by rajamohammed
        I used this URL. But it is taking as ftp:\username:p assword@servern ame\filepath\fi lename. 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.

        Comment

        Working...