commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [configuration] reading full text of PropertiesConfiguration file in 2.0
Date Mon, 14 Nov 2016 17:21:03 GMT
Hi Robert,

Am 12.11.2016 um 03:47 schrieb Robert V Sasseen:
> Is there a straightforward way to get the full text of the properties file from a PropertiesConfiguration
object in 2.0? In 1.x I could do
>         PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration("");
>         URL url = propertiesConfiguration.getURL();
>         String cont = IOUtils.toString((InputStream) url.openConnection().getContent(),
> This worked for both properties file in my jar and in the filesystem on the classpath.
But in 2.0 PropertiesConfiguration does not have a method getURL().
> Since PropertiesConfiguration has a (somewhat) complicated algorithm for finding properties
in the classpath and filesystem, I want to let it carry out its algorithm, then ask it where
it found the file, rather than having to try to understand and replicate the algorithm.
> If you're wondering why I want the text, I want to be able to show my user exactly what
the file looks like, even if it's hidden away in a jar file. I know (a little) about PropertiesConfigurationLayout,
but I'd prefer to just get the file text rather than reconstruct an approximation of it using
If you use a FileBasedConfigurationBuilder to create the
PropertiesConfiguration, you should be able to use the builder's
getFileHandler() method to obtain a FileHandler object. This object has
methods that allow you to retrieve the underlying file or URL.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message