Skip to content

Instantly share code, notes, and snippets.

@e7
Last active December 12, 2017 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e7/034ebda9527d6ad8ac1905e7faf71e7a to your computer and use it in GitHub Desktop.
Save e7/034ebda9527d6ad8ac1905e7faf71e7a to your computer and use it in GitHub Desktop.
apache commons configuration2 read config from both local and network
XMLConfiguration cnf;
{ // remote
cnf = new BasicConfigurationBuilder<>(XMLConfiguration.class)
.configure(new Parameters().xml()).getConfiguration();
InputStream is = new ByteArrayInputStream(
"xxxxxxxxxxxx".getBytes()
);
new FileHandler(cnf).load(is);
}
{ // local
cnf = new FileBasedConfigurationBuilder<>(XMLConfiguration.class)
.configure(new Parameters().xml().setFileName("xxxxxxx"))
.getConfiguration();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment