org.springframework.util.PropertiesPersister#loadFromXml ( )源码实例Demo

下面列出了org.springframework.util.PropertiesPersister#loadFromXml ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}
 
/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}
 
源代码3 项目: lams   文件: PropertiesLoaderUtils.java
/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}
 
/**
 * Actually load properties from the given EncodedResource into the given Properties instance.
 * @param props the Properties instance to load into
 * @param resource the resource to load from
 * @param persister the PropertiesPersister to use
 * @throws IOException in case of I/O errors
 */
static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
		throws IOException {

	InputStream stream = null;
	Reader reader = null;
	try {
		String filename = resource.getResource().getFilename();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			stream = resource.getInputStream();
			persister.loadFromXml(props, stream);
		}
		else if (resource.requiresReader()) {
			reader = resource.getReader();
			persister.load(props, reader);
		}
		else {
			stream = resource.getInputStream();
			persister.load(props, stream);
		}
	}
	finally {
		if (stream != null) {
			stream.close();
		}
		if (reader != null) {
			reader.close();
		}
	}
}