1:import java.io.*;
 2:import java.util.*;
 3:
 4:public class PropTest {
 5:
 6:    public PropTest() {
 7:    }
 8:
 9:    public static void main( String[] args ){
10:        PropTest prop = new PropTest();
11:        prop.readProperties();
12:    }
13:
14:    public void writeProperties(){
15:        try{
16:            OutputStream file = new BufferedOutputStream(
17:                new FileOutputStream( "c:\\test.properties" ) );
18:            Properties prop = new Properties();
19:            prop.setProperty("first_name", "Darcy" );
20:            prop.setProperty("last_name", "Schultz" );
21:            prop.store( file, null );
22:            file.close();
23:        }catch(Exception ex){
24:            ex.printStackTrace();
25:        }
26:    }
27:
28:    public void readProperties(){
29:        try{
30:            InputStream file = new BufferedInputStream(
31:                new FileInputStream( "c:\\test.properties" ) );
32:            Properties prop = new Properties();
33:            prop.load( file );
34:            prop.list( System.out ) ;
35:            file.close();
36:        } catch (Exception ex) {
37:            ex.printStackTrace();
38:        }
39:    }
40:}
1