Using Properties file in java

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.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
Post a Comment