Geeting the path of a file...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Srireddy
    New Member
    • Mar 2007
    • 7

    Geeting the path of a file...

    Hi, I pass a file name or a directory name to the java code, It should show me the correct path where that file or folder is present... Can any one help me with some idea please...... quick responce is highly appreciated.... ..
    Regards
    Srinivasa Reddy
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Suppose I pass it the name "foo" and both /a/foo and /b/foo are present in the
    file system. What is your program supposed to do? Find one instance? Find
    them all?

    kind regards,

    Jos

    Comment

    • Srireddy
      New Member
      • Mar 2007
      • 7

      #3
      Hi Jos,
      Thanks for the quick reply, I want to find all the files with that name no matter which folder it may be.....
      Regards,
      Srinivasa Reddy



      Originally posted by JosAH
      Suppose I pass it the name "foo" and both /a/foo and /b/foo are present in the
      file system. What is your program supposed to do? Find one instance? Find
      them all?

      kind regards,

      Jos

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by Srireddy
        Hi Jos,
        Thanks for the quick reply, I want to find all the files with that name no matter which folder it may be.....
        Regards,
        Srinivasa Reddy
        Check out the methods of the File class then; it has all the method
        you need. Start at the root(s) of your file system and traverse the entire
        directory hierarchy recursively; keep printing out the absolute path name
        of the current file/directory if it matches your criteria.

        kind regards,

        Jos

        Comment

        • Srireddy
          New Member
          • Mar 2007
          • 7

          #5
          thanks Jos,
          thanks for your suggestion.... I will try it and get back to you if i have any issues...
          Thanks once again....

          Originally posted by JosAH
          Check out the methods of the File class then; it has all the method
          you need. Start at the root(s) of your file system and traverse the entire
          directory hierarchy recursively; keep printing out the absolute path name
          of the current file/directory if it matches your criteria.

          kind regards,

          Jos

          Comment

          Working...