import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class ReadPropertiesSample { private static Properties configuration = new Properties(); private static String path = "PropertiesSample.properties"; static { try{ InputStream cf = ReadPropertiesSample.class.getResourceAsStream(path); configuration.load(cf); cf.close(); } catch(IOException e){ System.out.println(e.getStackTrace()); } } public static void main(String[] args) { System.out.printf("%s=[%s]\n", "caption",configuration.getProperty("caption")); System.out.printf("%s=[%s]\n", "comment",configuration.getProperty("comment")); } }