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 2 of 2

Thread: Finding full path of file

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,684
    Thanks
    25
    Thanked 333 Times in 309 Posts

    Default Finding full path of file

    I'll keep this short and sweet: Given a fragment of the beginning of a full file path, and a fragment of the ending of a full file path, is there an easy way to get the full file path (ie: find the file)?

    For example, let's say we have a full file with the path: C:\User\foo\fod\tee\few\file.txt
    Given:
    1. C:\User\foo
    2. few\file.txt

    Can I easily find the full path?

    My fall-back plan is recursion, but if Java already has some obscure built-in way to do this, it would save me some trouble. The only reason I am asking is because I just stumbled upon java's nio package, which seems like if the functionality already exists, it would be hidden somewhere in there.

    EDIT: for reference: http://docs.oracle.com/javase/7/docs...e-summary.html
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,123
    Thanks
    52
    Thanked 2,285 Times in 2,256 Posts

    Default Re: Finding full path of file

    There can be many paths that have have the same starting and ending parts. The search method would have to return a list.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. This is a link to full executable jar file.
    By rajeshverma in forum Java Theory & Questions
    Replies: 26
    Last Post: June 30th, 2012, 04:17 AM
  2. I/O stream for reading and editing a file full of numbers
    By Harry Blargle in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: October 5th, 2011, 09:00 AM
  3. how to get value path file from jsp form- input type file
    By meeGoreng in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: October 4th, 2011, 12:05 AM
  4. Inputing file (.txt) and finding the highest number in the file
    By alf in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 15th, 2010, 09:11 AM
  5. how to get full path name from realtive path
    By priyanka3006 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: August 10th, 2009, 04:28 AM