Simple config loading


/ Published in: Java
Save to your folder(s)

I decided to use JSON configs, which is faster&simpler.

Config file structure:
PROPERTY_STRING_1=str

PROPERTY_STRING_2=str2


Copy this code and paste it in your HTML
  1. public static void loadConfig() {
  2. Properties prop = new Properties();
  3. InputStream input = null;
  4.  
  5. try {
  6. input = new FileInputStream("config.txt");
  7. prop.load(input);
  8.  
  9. String s = prop.getProperty("PROPERTY_STRING_1");
  10. } catch (IOException ex) {
  11. ex.printStackTrace();
  12. } finally {
  13. if (input != null) {
  14. try {
  15. input.close();
  16. } catch (IOException e) {
  17. e.printStackTrace();
  18. }
  19. }
  20. }
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.