
how to store key & values pair in property file? Note: In property file keys should be displayed in ascending order. please reply the answer as soon as possible. Thanking You

import java.io.*;
import java.util.*;
public class WritePropertiesFile {
public static void main(String[] args) {
try {
Properties properties = new Properties();
properties.setProperty("Natinal-Animal", "Tiger");
properties.setProperty("Natinal-Flower", "Lotus");
properties.setProperty("National-Bird", "Peacock");
File file = new File("file.properties");
FileOutputStream fos = new FileOutputStream(file);
properties.store(fos, "");
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.