`public class PropertiesUtils extends Properties {
private static final long serialVersionUID = 1L;
private static final String DEFAULT_PROPERTIES;
static {
DEFAULT_PROPERTIES = "config/application.properties";
}
@SuppressWarnings("unused")
private PropertiesUtils() {
}
public PropertiesUtils(@Nullable ClassLoader classLoader, String... configPath) {
String file = configPath.length == 0 ? DEFAULT_PROPERTIES : configPath[0];
Optional<InputStream> inStream = Optional.of(Optional.ofNullable(classLoader).orElseGet(() -> {
ClassLoader[] classLoaders = new ClassLoader[] { Thread.currentThread().getContextClassLoader(),
ClassLoader.getSystemClassLoader(), PropertiesUtils.class.getClassLoader() };
return Arrays.stream(classLoaders).filter(cl -> cl.getResourceAsStream(file) != null).findFirst().get();
}).getResourceAsStream(file));
if (inStream.isPresent())
try {
super.load(inStream.get());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}`