Results 1 to 3 of 3

Thread: file path

  1. #1
    billq is offline Member
    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Default file path

    Hello, I created a file in the directory where the java program was run called some.txt. How do I retrieve the full system path of the file?

    File x = new File("sometext.txt");
    if(!x.exists())
    x.createNewFile();
    System.out.println("The file has path " + x.getPath());
    the x.getPath() just returns the path relative to the working directory.

    thanks

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,335
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by billq View Post
    Hello, I created a file in the directory where the java program was run called some.txt. How do I retrieve the full system path of the file?

    File x = new File("sometext.txt");
    if(!x.exists())
    x.createNewFile();
    System.out.println("The file has path " + x.getPath());
    the x.getPath() just returns the path relative to the working directory.

    thanks
    Read the API documentation for the File class (again); it has the method you need.

    kind regards,

    Jos

  3. #3
    billq is offline Member
    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

Similar Threads

  1. ant with a jar file in path to run
    By javastuden in forum Advanced Java
    Replies: 0
    Last Post: 02-22-2010, 05:59 AM
  2. file path
    By ras_pari in forum Advanced Java
    Replies: 2
    Last Post: 10-12-2009, 11:25 AM
  3. reading file from a path
    By new_coder in forum New To Java
    Replies: 5
    Last Post: 08-17-2009, 04:52 AM
  4. How to set Image file path
    By anil.bharadia in forum AWT / Swing
    Replies: 1
    Last Post: 01-28-2009, 09:10 PM
  5. file path
    By Arsench in forum New To Java
    Replies: 7
    Last Post: 10-30-2008, 05:39 AM

Posting Permissions

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