package FileS;
import java.util.*;
import java.io.*;
import javax.servlet.*;
public class PropertiesT {
public static void main(String[] args) {
/*
* Properties pps=System.getProperties(); pps.list(System.out);
* properties file read
*/
//(1)****************************************
// InputStream in;
// try {
// in = new BufferedInputStream(new FileInputStream("d:/proTest.properties"));
// Properties p = new Properties();
// p.load(in);
//
// } catch (FileNotFoundException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//******************************************
//(2)******************************************
// ResourceBundle rb = ResourceBundle.getBundle("d:/proTest.properties", Locale.getDefault());
//******************************************
//(3)******************************************
// InputStream in;
// try {
// in = new BufferedInputStream(new FileInputStream("d:/proTest.properties"));
// ResourceBundle rb = new PropertyResourceBundle(in);
// } catch (FileNotFoundException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// } catch (IOException ex) {
// ex.printStackTrace();
// }
//******************************************
//(4)******************************************
// InputStream in = JProperties.class.getResourceAsStream("d:/proTest.properties");
// Properties p = new Properties();
// try {
// p.load(in);
// } catch (IOException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//******************************************
//(5)******************************************
// InputStream in = JProperties.class.getClassLoader().getResourceAsStream("d:/proTest.properties");
// Properties p = new Properties();
// try {
// p.load(in);
// } catch (IOException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//******************************************
//(6)******************************************
// InputStream in = ClassLoader.getSystemResourceAsStream("d:/proTest.properties");
// Properties p = new Properties();
// try {
// p.load(in);
// } catch (IOException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//******************************************
//(7)******************************************
// InputStream in = context.getResourceAsStream("d:/proTest.properties");
// Properties p = new Properties();
// p.load(in);
//******************************************
Properties pps = new Properties();
try {
pps.load(new FileInputStream("d:/proTest.properties"));
Enumeration ENUM = pps.propertyNames();
while (ENUM.hasMoreElements()) {
String str = (String) ENUM.nextElement();
String strValue = pps.getProperty(str);
System.out.println(str + " = " + strValue);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}