Java Code Examples for org.springframework.util.PropertiesPersister#load()

The following examples show how to use org.springframework.util.PropertiesPersister#load() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertiesLoaderUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * 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();
		}
	}
}
 
Example 2
Source File: PropertiesLoaderUtils.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 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();
		}
	}
}
 
Example 3
Source File: PropertiesLoaderUtils.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
		}
	}
}
 
Example 4
Source File: PropertiesLoaderUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
		}
	}
}