본문 바로가기

Programming!

java.util.Properties XML로 읽고 쓰기.

loadFromXML

storeToXML

규약이 있죠.

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">


ex)
Properties properties = new Properties();
try {
    InputStream xmlStream = getClass().getResourceAsStream("resource/xxxxx.xml");
    if( xmlStream == null ) {
         // null인데 어쩔껴.. 
    }            
    properties.loadFromXML(xmlStream);
} catch (IOException exception) {
    // throw exception
}



<
?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <entry key="keyName">keyValue</entry> </properties>