Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2020 16:06
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Example of Properties file read in Java with the Singleton pattern
public class ReadProperties {
private static final Logger LOG = LoggerFactory.getLogger(ReadProperties.class);
private static ReadProperties instance = null;
private Properties properties = null;
private ReadProperties() {
properties = new Properties();
try {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("");
} catch (IOException e) {
public static synchronized ReadProperties getInstance() {
if (instance == null) {
instance = new ReadProperties();
return instance;
public String getValue(String key) {
return, String.format("The key %s does not exists!", key));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment