Posts

Showing posts from July, 2020

Property Reader In Java

Sample Property Reader in Java public class PropertyReader { private static Properties properties = new Properties(); static { try { ClassLoader classLoader = Thread. currentThread ().getContextClassLoader(); InputStream inputStream = classLoader.getResourceAsStream( "filename.properties" ); properties = new Properties(); properties .load(inputStream); inputStream.close(); } catch (Exception ex) { ex.printStackTrace(); } } public static boolean containsKey(String key) { if ( properties .containsKey(key)) { return true ; } return false ; } public static String getPropertyValue(String key) { if ( properties .containsKey(key)) { return (String) properties .get(key); } return null ; } public static void setPropertyValue(String key, String value) { ...