Properties文件的XML格式
想必大家都用过*.properties文件,作为配置文件。但是,如果该文件写入了中文,待编译后内容就会成为乱码,使用native命令也好、使用ant执行编码转换也好,多少有点麻烦,与其如此,我们不如直接使用properties的xml格式。<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><comment>logoLocation</comment><entry key="logoLocation"><!]></entry><entry key="mail.host"><!]></entry><entry key="site.name"><!]></entry></properties>
对应原有的properties文件
#logoLocationlogoLocation=/image/logo/mail.host=webmaster@zlex.orgsite.name=zlex中文网站
读取\存储:
Properties.loadFromXML(InputStream in) Properties.storeToXML(OutputStream os, String comment, String encoding)
页:
[1]