Reputation: 1717
I have inherited a code base. The code is loading a file called "my.properties". That file is being loaded via the following code:
public SomeConstructor(String filePath) {
FileInputStream stream = new FileInputStream("my.properties");
...
}
The code works. My problem is, the code I inherited has "my.properties" files all over the place (I'm talking 50 places). So I can't figure out which "my.properties" is actually being loaded. How can I print out the full path of the file loaded into the FileInputStream
?
Upvotes: 0
Views: 65
Reputation: 315
I think this link may help you out.click here
The FileInputStream has a method called getFD() which gives you an object that describes the file. hope this is what your looking for.
Upvotes: 0
Reputation: 2140
The File.getAbsolutePath() will give you the full complete path name (filepath + filename) of a file.
File file = new File("my.properties");
System.out.println("Path : " + file.getAbsolutePath());
Hope this helps!
Upvotes: 0
Reputation: 1135
Do: System.out.println(new File("my.properties").getAbsolutePath());
Upvotes: 3