Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 706 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read file from resources folder in Spring Boot

#21
Try this:

In application.properties

app.jsonSchema=classpath:jsonschema.json

On your Properties pojo:

**NOTE**: You can use any prefered way of reading configs from application.properties.

@Configuration
@ConfigurationProperties(prefix = "app")
public class ConfigProperties {
private Resource jsonSchema;

// standard getters and setters
}

In your class, read the resource from the Properties Pojo:

//Read the Resource and get the Input Stream
try (InputStream inStream = configProperties.getJsonSchema().getInputStream()) {
//From here you can manipulate the Input Stream as desired....
//Map the Input Stream to a Map
ObjectMapper mapper = new ObjectMapper();
Map <String, Object> jsonMap = mapper.readValue(inStream, Map.class);
//Convert the Map to a JSON obj
JSONObject json = new JSONObject(jsonMap);
} catch (Exception e) {
e.printStackTrace();
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through