i need to make that my app shows the specific value in xml file should i use scanner? or there is another way i need to extract
# Rate Exp Sp RateXp = 4. RateSp = 4.
the value of for example this^
actually not the xml but .properities
Get your .properties file as an input stream, then
final var properties = new Properties();
try (InputStream is = ...) {
.load(is);
properties}
Easy peasy, then just
.getProperty("RateXp"); properties
Full example:
public record Config(int rateXp, int rateSp) {
public static Config loadFromClasspath() {
final var properties = new Properties();
try (final var inputStream = getClass().getClassLoader().getResourceAsStream("config.properties")) {
.load(inputStream);
properties}
catch (IOException e) {
throw new UncheckedIOException(e);
}
return new Config(
Integer.parseInt(properties.getProperty("RateXp")),
Integer.parseInt(properties.getProperty("RateSp"))
);
}
}