Results 1 to 8 of 8
  1. #1
    260191894 is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Absolute path for a file in Java?

    Hi everyone!

    I am trying to write Java programs that can access files. Is there a way that my program can access a file no matter where it is in the system without knowing the location? Currently, the program can only upload the file if it is the same directory.

    Thank you very much for your time!

  2. #2
    lilezek is offline Member
    Join Date
    Jun 2012
    Posts
    23
    Rep Power
    0

    Default Re: Absolute path for a file in Java?

    Do you mean to locate a file in whole filesystem? Do you know how expensive could it be?

    Actually my main filesystem (I have 3 filesystems plus the main) contains 584194 files.

    Do you have any aditional information of the location of the file?

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default Re: Absolute path for a file in Java?

    You always specify a path name: if you only specify the base name, the file has to be located in the 'current working directory', otherwise the path can be a relative path (and relative to this current working directory) or an absolute path name.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    260191894 is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Re: Absolute path for a file in Java?

    Quote Originally Posted by JosAH View Post
    You always specify a path name: if you only specify the base name, the file has to be located in the 'current working directory', otherwise the path can be a relative path (and relative to this current working directory) or an absolute path name.

    kind regards,

    Jos
    Hi Jos!

    What does the absolute path name require?

    Thank you!

  5. #5
    260191894 is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Re: Absolute path for a file in Java?

    Hi lilezek!

    I want to use the absolute path but I don't know what it includes because when the compiler keeps saying "file not found".

    Thank you!

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default Re: Absolute path for a file in Java?

    Quote Originally Posted by 260191894 View Post
    What does the absolute path name require?
    Every path name starting with a '/' character is an absolute path name; Microsoft file systems know about more roots: "/C:", "D:" etc.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    260191894 is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Re: Absolute path for a file in Java?

    I am using Apple OSX with a user account. When I click on "get info" for a file, the system gives me /User/.... I assume that is the absolute path file?

    Thank you!

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default Re: Absolute path for a file in Java?

    Quote Originally Posted by 260191894 View Post
    I am using Apple OSX with a user account. When I click on "get info" for a file, the system gives me /User/.... I assume that is the absolute path file?
    It starts with a '/' character, so according to the definition, it's an absolute path name.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 4
    Last Post: 03-21-2011, 04:45 AM
  2. Add a jar file to Java load path at run time
    By marioneil in forum Advanced Java
    Replies: 5
    Last Post: 09-22-2010, 07:58 AM
  3. Replies: 1
    Last Post: 04-23-2010, 09:27 PM
  4. File path validation in Java
    By aks123 in forum Advanced Java
    Replies: 2
    Last Post: 10-07-2009, 04:38 PM
  5. Specifying absolute path in web.xml
    By Felissa in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-05-2007, 06:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •