This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to get file path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to get file path" Watch "how to get file path" New topic

how to get file path

Jherald Lacambra
Ranch Hand

Joined: Feb 02, 2005
Posts: 129
when i use the System.getProperty("user.dir") i get the current working directory.. i want to get the absolute file path of a text file... how can this be done?

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24190

Where is the text file?

[Jess in Action][AskingGoodQuestions]
Jherald Lacambra
Ranch Hand

Joined: Feb 02, 2005
Posts: 129
outside the directory of the class dile that calls the text file
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Look at the File class. You'll find several methods that give you different forms of paths. The doc is a bit confusing, so try some of them and see what they mean.

Does that answer the right question?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Have you checked out Aspose?
subject: how to get file path
It's not a secret anymore!