import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.InvalidPropertiesFormatException;
import java.util.Properties;
public class PropertiesDemo04 {
public static void main(String[] args) {
Properties pro = new Properties();
pro.setProperty("BJ", "Beijing");
pro.setProperty("DJ", "TOKYO");
pro.setProperty("DB", "oSA");
File file = new File("E:" + File.separator + "area.xml");
try {
pro.storeToXML(new FileOutputStream(file), "AREA INFO");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
pro.loadFromXML(new FileInputStream(file));
} catch (InvalidPropertiesFormatException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("DJ:" + pro.getProperty("DJ"));
}
}