A)
->java.util.Properties is a sub class of java.util.Hashtable.
->object oriented representation of a properties file is nothing but properties object.
->some information is given to servlets or container etc… by using this properties class. The file (secondary memory file) is represented as object oriented representation.
Ex:
database properties
database properties
User :scott
Password:tiger
importjava.util.Properties;
importjava.util.Properties;
import java.io.*;
class propertiestest {
public static void main(String[] args) throws Exception{
FileInputStream fis = new FileInputStream ("database.properties");
Properties p = new Properties();
p.load(fis);
System.out.println(p.getProperty("user"));
System.out.println(p.getProperty("password"));
p.setProperty("mail", "username.@gmail.com");
FileOutputStream fos = new FileOutputStream("database.property");
p.store(fos, "some database some personal");
fos.close();
fis.close();
}
}
Comments
Post a Comment