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("my.properties"); > > URL url = propertiesConfiguration.getURL(); > String cont = IOUtils.toString((InputStream) > url.openConnection().getContent(), StandardCharsets.UTF_8); > > > 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 that. > 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.
Oliver --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org