To load a properties file bundled with your application:
public class Defaults {
public static Properties loadDefaults() {
try (InputStream bundledResource =
Defaults.class.getResourceAsStream("defaults.properties")) {
Properties defaults = new Properties();
defaults.load(bundledResource);
return defaults;
} catch (IOException e) {
// Since the resource is bundled with the application,
// we should never get here.
throw new UncheckedIOException(
"defaults.properties not properly packaged"
+ " with application", e);
}
}
}