Sunday, May 29, 2011

Property class example in java

Here is an example of reading in a properties file, removing the password and printing out the reminder.
import java.util.*;
import java.io.*;

public class PropertyDemo {

public static void main(String[] args) 
                         throws Exception {

BufferedInputStream bStream = new BufferedInputStream
              (new FileInputStream("prefs.ini"));
Properties props = new Properties();
props.load(bStream);
props.remove("password");
props.list(System.out);
bStream.close();
}
} 

No comments:

Post a Comment

Chitika