Reputation: 3963
An instance of java.util.Properties
is passed to me which has been created using:
[...]
properties = new java.util.Properties();
try {
properties.load(
AutoProperties.class.getClassLoader().getResourceAsStream(propertyFile)
);
}
[...]
I was wondering how I could retrieve the file name (propertyFile
above) from the properties
instance? I had a glance at the API and couldn't see any easy way to do it.
Upvotes: 2
Views: 2302
Reputation: 81627
You cannot get this information, as a Properties
object is not necessarily linked to a File...
Indeed, you can populate the Properties
in several ways:
put()
method from the Hashtable class).Upvotes: 1
Reputation: 147164
The file name (or path name in this case) is not stored in the Properties
instance. In fact, you haven't even passed the name to the instance.
Upvotes: 6