-1

Lets say that I have a file name config.yml and I am using the properties object to get properties. I want to file be edited by the notepad++ and the regular notepad and it will stay what the file already have in it.

Properties prop = new Properties();
prop.setProperty("test", "20");
prop.store(file, null);
System.out.println(prop.getProperty("test");

The output is 20 but I want it to change to whatever the file say it is. How can you edit the file in a program like notepad++ and get a different output like 30 for a example?

  • 1
    It is unclear what you are asking, could you [edit] your question to clarify? Also, a [YAML](http://yaml.org/) file is completely different from a Java properties file. – Just a student Sep 26 '17 at 12:04
  • 1
    Possible duplicate of [How to reload properties file in java](https://stackoverflow.com/questions/9924502/how-to-reload-properties-file-in-java) – kryger Sep 26 '17 at 12:12

1 Answers1

0

To read the properties file, I created a simple program, performing the display of its contents on the console.

public static Properties getProp() throws IOException {
    Properties props = new Properties();
    FileInputStream file = new FileInputStream(
            "./properties/dados.properties");
    props.load(file);
    return props;

}

public static void  main(String args[]) throws IOException {
    String test;

    Properties prop = getProp();

    test = prop.getProperty("test");

    System.out.println("Test = " + test);

}
Gabriel Cardoso
  • 43
  • 1
  • 10