Skip to content

Instantly share code, notes, and snippets.

@siddharthbarman
Created July 11, 2020 08:38
Show Gist options
  • Select an option

  • Save siddharthbarman/a160ca2ea995f3f8e50d61cf1a1cb11d to your computer and use it in GitHub Desktop.

Select an option

Save siddharthbarman/a160ca2ea995f3f8e50d61cf1a1cb11d to your computer and use it in GitHub Desktop.

Revisions

  1. siddharthbarman created this gist Jul 11, 2020.
    13 changes: 13 additions & 0 deletions Application.java
    Original 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());
    }
    }
    }
    33 changes: 33 additions & 0 deletions ApplicationProperties.java
    Original 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";
    }
    2 changes: 2 additions & 0 deletions application.properties
    Original 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