Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Simple config loading [SRC]

use JSON configs, which is faster&simpler.

Config file structure: PROPERTYSTRING1=str

PROPERTYSTRING2=str2

PHP Code

<?php 
public static void loadConfig() {
        
Properties prop = new Properties();
        
InputStream input = null;
 
        try {
            
input = new FileInputStream("config.txt");
            
prop.load(input);
 
            
String s = prop.getProperty("PROPERTY_STRING_1");
        } catch (
IOException ex) {
            
ex.printStackTrace();
        } finally {
            if (
input != null) {
                try {
                    
input.close();
                } catch (
IOException e) {
                    
e.printStackTrace();
                }
            }
        }
    } 

Enjoy 🎉🎉🎉🎉🎉
This code is outdated, as you should be using a try-with-resources statement so you don't have to worry about closing the stream.

Also you noted to use JSON configs but provided code for a text file. What was the point?

You should really explain to everyone about what your code does instead of just blindly posting it.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by m00dyJun 8, 2015 07:48 PM 7 364 Jun 8, 2015 07:48 PM
Last Post: LeKlutch
[.NET] by SIM-1456245Feb 28, 2014 11:14 AM 9 411 Feb 28, 2014 11:14 AM
Last Post: djvirushackpro
[.NET] by pcprJul 1, 2013 12:30 PM 6 205 Jul 1, 2013 12:30 PM
Last Post: Washi