Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Access to a shared folder over LAN

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Location
    Kingston, Jamaica
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Access to a shared folder over LAN

    Hello, everyone. I would like to know how to connect to and gain access to a shared network folder. I presume I need a login for that share folder. Can a URL construct be used?


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Access to a shared folder over LAN

    Use whatever the address of the file is (in general it's //{computer address}/{rest of address})

    So, for example, to access a computer with an ip address of 192.168.0.4 inside a folder called share:

    File file = new File("//192.168.0.4/share/theFile.txt");

    If you can access the other computer via the name, you can just use the name instead of the IP address.

    File file = new File("//HostComputer/share/theFile.txt");

    Lastly, you can access via the url as well.

    File file = new File("http://www.javaprogrammingforums.com/java-networking/4902-access-shared-folder-over-lan.html");

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Location
    Kingston, Jamaica
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access to a shared folder over LAN

    Thanks for your speedy response. What I did already is exactly what you (or anyone else) probably would have suggested. My real problem is: creating the file object from the actual path works. However, what if the share folder needs authentication, which is the case with most Windows machine.

  4. #4
    Junior Member
    Join Date
    Jul 2010
    Location
    Kingston, Jamaica
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access to a shared folder over LAN

    Before I go any further. I probably should ask for suggests to the best possible route to achieve the follwoing:

    1. I want to get a file name externally ( the name of an image file, .jpg)
    The file names are within Oracle database. This part is fairly easy.

    2. Search a remote folder ( the share folder on the LAN that contains all the image files; the share folder requires authentication.

    3. Return the image file when found.


    The found image file will be used in a HTML context. I am not sure how to implement this.

    Im thinking about just returning the absolute path to the image file when it is found, this path will be embedded in the img tag. As I said I am not sure how to proceed. SUGGESTIONS PLEASE.

  5. #5
    Junior Member
    Join Date
    Jul 2010
    Location
    Kingston, Jamaica
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Access to a shared folder over LAN

    Would an applet carry out this function?

Similar Threads

  1. Shared library path
    By sateesh.b in forum Java Native Interface
    Replies: 3
    Last Post: May 13th, 2010, 11:12 PM
  2. creating a shared library
    By navinbecse in forum Threads
    Replies: 1
    Last Post: April 9th, 2010, 07:54 AM
  3. Getting information from a folder
    By shadihrr in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: February 23rd, 2010, 04:13 PM
  4. Default Access (package access) confusion
    By gauravrajbehl in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2009, 04:11 AM
  5. Java program to take new files from one path and sent it do another path?
    By jazz2k8 in forum File I/O & Other I/O Streams
    Replies: 11
    Last Post: July 8th, 2008, 06:47 AM

Tags for this Thread