java get properties file

  • 91
  • 0

java get properties file

// String title = "行政院農業委員會農糧署";
        InputStream inputStream = this.getClass().getClassLoader()
                .getResourceAsStream("Messages.properties");
        Properties properties = new Properties();
        // load the inputStream using the Properties
        try {
            properties.load(inputStream);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            throw new RuntimeException(e);
        }
        // get the value of the property
        String propValue = properties.getProperty("reportTitle");
        log.info("propValue" + propValue);
        builder.addParameter("reportTitle", propValue);