Using Properties file in java

House 12 Clip Art at Clker.com - vector clip art online, royalty ...
In the general case .properties file used to store project configuration & data configuration setting as special chunk of text.

They are store as key value pairs.

In java it also called as Resource Bundle.
By default java java System class has properties & we can use that as internal & external file s also

import java.io.File;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Paths;
import java.util.Properties;

public class AppInizializer {
    public static void main(String[] args) {
    //get all properties in System class
        Properties properties = System.getProperties(); 
        for (Object key : properties.keySet()) {
            System.out.println(key + "=" + properties.get(key));
        }

//(a)JVM invoking place using property file        
        System.out.println(System.getProperty("user.dir"));

//Cheack its validity of(a)
        System.out.println(new File("").getAbsolutePath());
        System.out.println(FileSystems.getDefault().getPath("").toAbsolutePath());
        System.out.println(Paths.get("").toAbsolutePath());
    }
}

Comments

Popular posts from this blog

Hibernate-2

Hibernate-1

Avoid Round-off error in large & Small numbers using BigDecimal Class in Java