解析这种properties文件,需要注意。

配置xml配置文件如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="zfdxc.webinfDir">/WEB-INF</entry>
<entry key="connection.poolname">zfdxc</entry>
<entry key="connection.initialPoolSize"/>
<entry key="quartz.isuse">false</entry>
<entry key="zfdxc.console.usr">zfdxc</entry>
<entry key="zfdxc.xtbh">0</entry>
<entry key="zfdxc.jobDir">/WEB-INF/job</entry>
<entry key="zfdxc.logfilepath"/>
<entry key="zfdxc.logDir">/zfdxcLog</entry>
<entry key="zfdxc.jobConfig.filepath">/WEB-INF/job/job-config.xml</entry>
<entry key="connection.port">1521</entry>
<entry key="zfdxc.contextPath">/zfdxc</entry>
<entry key="zfdxc.picDir">/zfdxcPic</entry>
<entry key="connection.accesstype">Native</entry>
<entry key="zfdxc.locale">zh_CN</entry>
<entry key="zfdxc.headini.filepath">/common/head.ini</entry>
<entry key="zfdxc.charset">GBK</entry>
<entry key="connection.password">gnd8bFTenCx5kI9f9xZQZQ==</entry>
<entry key="zfdxc.logIsDebugConsole">true</entry>
<entry key="connection.servicename">orcl</entry>
<entry key="quartz.startDelayed">12</entry>
<entry key="connection.username">gnd8bFTenCx5kI9f9xZQZQ==</entry>
<entry key="zfdxc.console.pwd">Encrypted 2be98afc86aa7f2e4cb79ce6ad896b7d9</entry>
<entry key="connection.dbtype">ORACLE</entry>
<entry key="zfdxc.headini.rebuild">false</entry>
<entry key="connection.host">10.71.32.190</entry>
<entry key="zfdxc.css">/zfstyle/style/standard/zfdxc.css</entry>
<entry key="zfdxc.webRoot">/</entry>
<entry key="zfdxc.fileDir">/zfdxcFile</entry>
<entry key="zfdxc.logfileCharset"/>
<entry key="zfdxc.uploadDir">/zfdxcUpload</entry>
<entry key="zfdxc.loglevel">Basic</entry>
<entry key="connection.maximumPoolSize"/>
</properties>


解析代码如下:


public static boolean xmlZfdxcDataSourceUpdate(String filePath,
DataSourcePojo dataSourcePojo) {
Properties pps = new Properties();
FileOutputStream fos = null;
try {
pps.loadFromXML(new FileInputStream(filePath));
pps
.setProperty(
DataSourcePropertyFactory.ZFDXC__DATASOURCE_CONNECTION_HOST,
dataSourcePojo.getIpAddress());
pps
.setProperty(
DataSourcePropertyFactory.ZFDXC__DATASOURCE_CONNECTION_PORT,
dataSourcePojo.getPort());
pps
.setProperty(
DataSourcePropertyFactory.ZFDXC__DATASOURCE_CONNECTION_SERVICENAME,
dataSourcePojo.getDbname());
pps.setProperty(DataSourcePropertyFactory.ZFDXC__DATASOURCE_USER,
dataSourcePojo.getUserId());
pps.setProperty(DataSourcePropertyFactory.ZFDXC__DATASOURCE_PWD,
dataSourcePojo.getUserPwd());
fos = new FileOutputStream(filePath);
pps.storeToXML(fos, null);// prop.storeToXML(fos,
fos.close();// The specified stream remains open after storeToXML()
// returns,so must close obviously
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
}
}
}
return true;
}

你可能感兴趣的:(解析这种properties文件,需要注意。)