Created
July 11, 2020 08:38
-
-
Save siddharthbarman/a160ca2ea995f3f8e50d61cf1a1cb11d to your computer and use it in GitHub Desktop.
Revisions
-
siddharthbarman created this gist
Jul 11, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ package com.sbytestream.sample; public class Application { public static void main(String[] args) { try { ApplicationProperties applicationProperties = new ApplicationProperties(); System.out.println(applicationProperties.getSignatureFetchUrl()); } catch(Exception e) { System.out.println(e.getMessage()); } } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ package com.sbytestream.sample; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class ApplicationProperties { public ApplicationProperties() throws IOException { load(); } private void load() throws IOException { Properties properties = new Properties(); InputStream is = getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE); if (is != null) { properties.load(is); } else { throw new FileNotFoundException(PROPERTIES_FILE + " not found"); } signatureFetchUrl = properties.getProperty("app.signature-fetch-url"); is.close(); } public String getSignatureFetchUrl() { return signatureFetchUrl; } private String signatureFetchUrl; private final String PROPERTIES_FILE = "application.properties"; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ # File location: src/main/resources/ app.signature-fetch-url=http://localhost:8082/signatures