当前位置: 首页>>代码示例>>Java>>正文


Java Resource.getInputStream方法代码示例

本文整理汇总了Java中org.springframework.core.io.Resource.getInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getInputStream方法的具体用法?Java Resource.getInputStream怎么用?Java Resource.getInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.io.Resource的用法示例。


在下文中一共展示了Resource.getInputStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
public void load() throws Exception {

        if(client == null) {
            return;
        }

        List<Resource> resources = Arrays.asList(schemaResource);

        for(Resource resource : resources) {
            try(InputStream is = resource.getInputStream()) {
                String schema = IOUtils.toString(is);
                client.submit(schema).all().get();
            }
        }
    }
 
开发者ID:experoinc,项目名称:spring-boot-graph-day,代码行数:16,代码来源:SchemaLoader.java

示例2: PublicKeyspacePersistenceSettings

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * Constructs Ignite cache key/value persistence settings.
 *
 * @param settingsRsrc resource containing xml with persistence settings for Ignite cache key/value
 */
public PublicKeyspacePersistenceSettings(Resource settingsRsrc) {
    InputStream in;
    try {
        in = settingsRsrc.getInputStream();
    }
    catch (IOException e) {
        throw new IgniteException("Failed to get input stream for Cassandra persistence settings resource: " +
            settingsRsrc, e);
    }
    try {
        init(loadSettings(in));
    }
    finally {
        U.closeQuiet(in);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:22,代码来源:PublicKeyspacePersistenceSettings.java

示例3: loadProperties

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * 载入多个文件, 文件路径使用Spring Resource格式.
 */
private Properties loadProperties(String... resourcesPaths) {
	Properties props = new Properties();

	for (String location : resourcesPaths) {

		//			logger.debug("Loading properties file from:" + location);

		InputStream is = null;
		try {
			Resource resource = resourceLoader.getResource(location);
			is = resource.getInputStream();
			props.load(is);
		} catch (IOException ex) {
			logger.info("Could not load properties from path:" + location + ", " + ex.getMessage());
		} finally {
			IOUtils.closeQuietly(is);
		}
	}
	return props;
}
 
开发者ID:funtl,项目名称:framework,代码行数:24,代码来源:PropertiesLoader.java

示例4: getSettings

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * Returns the settings used for creating this jar. This method tries to
 * locate and load the settings from the location indicated by
 * {@link #getSettingsLocation()}. If no file is found, the default
 * settings will be used.
 * <p/>
 * <p/> A non-null properties object will always be returned.
 *
 * @return settings for creating the on the fly jar
 * @throws Exception if loading the settings file fails
 */
protected Properties getSettings() throws Exception {
    Properties settings = new Properties(getDefaultSettings());
    // settings.setProperty(ROOT_DIR, getRootPath());
    Resource resource = new ClassPathResource(getSettingsLocation());

    if (resource.exists()) {
        InputStream stream = resource.getInputStream();
        try {
            if (stream != null) {
                settings.load(stream);
                logger.debug("Loaded jar settings from " + getSettingsLocation());
            }
        } finally {
            IOUtils.closeStream(stream);
        }
    } else {
        logger.info(getSettingsLocation() + " was not found; using defaults");
    }

    return settings;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:33,代码来源:AbstractConfigurableBundleCreatorTests.java

示例5: loadPropertiesFromPaths

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private static Properties loadPropertiesFromPaths(ResourceLoader resourceLoader, List<String> paths) {
	Properties configurationProperties = new Properties();
	for (String path : paths) {
		Resource resource = resourceLoader.getResource(path);
		InputStream is = null;
		try {
			is = resource.getInputStream();
			Properties properties = new Properties();
			properties.loadFromXML(is);
			configurationProperties.putAll(properties);
		} catch (IOException ex) {
			log.error("Failed to load configuration properties. Resource - " + path, ex);
		} finally {
			try {
				if (is != null) {
					is.close();
				}
			} catch (IOException ioe) {
				// ignore
				ioe.printStackTrace();
			}
		}
	}
	return configurationProperties;
}
 
开发者ID:profullstack,项目名称:spring-seed,代码行数:26,代码来源:ProfileApplicationContextInitializer.java

示例6: getKeyStore

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private KeyStore getKeyStore(Resource resource, String password) throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException {

        try (InputStream stream = resource.getInputStream()) {
            KeyStore keyStore;

            String filename = resource.getFilename().toLowerCase();
            if (filename.endsWith("pfx") || filename.endsWith("p12")) {
                keyStore = KeyStore.getInstance("PKCS12");
            } else {
                keyStore = KeyStore.getInstance("JKS");
            }

            keyStore.load(stream,password.toCharArray());

            return keyStore;
        }
    }
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:18,代码来源:SSLHelper.java

示例7: loadFromApplicationConfig

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private static SessionSettings loadFromApplicationConfig(String applicationConfigLocation) throws ConfigError, IOException {
    Resource resource;
    if (applicationConfigLocation != null) {
        resource = loadResource(applicationConfigLocation);
        if (resource != null && resource.exists()) {
            logger.info("Loading settings from application property '" + applicationConfigLocation + "'");
            return new SessionSettings(resource.getInputStream());
        }
    }
    return null;
}
 
开发者ID:esanchezros,项目名称:quickfixj-spring-boot-starter,代码行数:12,代码来源:SessionSettingsLocator.java

示例8: getSigningCredential

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * getSigningCredential loads up an X509Credential from a file.
 *
 * @param resource the signing certificate file
 * @return an X509 credential
 */
private Credential getSigningCredential(final Resource resource) {
    try (InputStream inputStream = resource.getInputStream()) {
        final CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
        final X509Certificate certificate = (X509Certificate) certificateFactory.generateCertificate(inputStream);
        final Credential publicCredential = new BasicX509Credential(certificate);
        logger.debug("getSigningCredential: key retrieved.");
        return publicCredential;
    } catch (final Exception ex) {
        logger.error(ex.getMessage(), ex);
        return null;
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:WsFederationConfiguration.java

示例9: loadProperties

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
@Override
protected Properties loadProperties(Resource resource, String filename) throws IOException {
	Map<String, String> result;
	try (InputStream in = resource.getInputStream()) {
		result = objectMapper.readValue(in, objectMapper.constructType(TYPE_STRING_MAP));
	}
	addMetadata(filename, result);
	process(result);
	Properties properties = new Properties();
	properties.putAll(result);
	return properties;
}
 
开发者ID:yushijinhun,项目名称:akir,代码行数:13,代码来源:JsonMessageSource.java

示例10: createManifestFrom

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private Manifest createManifestFrom(Resource resource) {
	Assert.notNull(resource, "unable to create manifest for empty resources");
	try {
		return new Manifest(resource.getInputStream());
	}
	catch (IOException ex) {
		throw (RuntimeException) new IllegalArgumentException("cannot create manifest from " + resource).initCause(ex);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:AbstractOnTheFlyBundleCreatorTests.java

示例11: loadProperties

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * Load the properties from the given resource.
 * @param resource the resource to load from
 * @param filename the original bundle filename (basename + Locale)
 * @return the populated Properties instance
 * @throws IOException if properties loading failed
 */
protected Properties loadProperties(Resource resource, String filename) throws IOException {
	InputStream is = resource.getInputStream();
	Properties props = new Properties();
	try {
		if (resource.getFilename().endsWith(XML_SUFFIX)) {
			if (logger.isDebugEnabled()) {
				logger.debug("Loading properties [" + resource.getFilename() + "]");
			}
			this.propertiesPersister.loadFromXml(props, is);
		}
		else {
			String encoding = null;
			if (this.fileEncodings != null) {
				encoding = this.fileEncodings.getProperty(filename);
			}
			if (encoding == null) {
				encoding = this.defaultEncoding;
			}
			if (encoding != null) {
				if (logger.isDebugEnabled()) {
					logger.debug("Loading properties [" + resource.getFilename() + "] with encoding '" + encoding + "'");
				}
				this.propertiesPersister.load(props, new InputStreamReader(is, encoding));
			}
			else {
				if (logger.isDebugEnabled()) {
					logger.debug("Loading properties [" + resource.getFilename() + "]");
				}
				this.propertiesPersister.load(props, is);
			}
		}
		return props;
	}
	finally {
		is.close();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:ReloadableResourceBundleMessageSource.java

示例12: loadProperties

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private void loadProperties(Resource resource, Properties properties) throws IOException {
	if (resource != null) {
		if (log.isDebugEnabled()) {
			log.debug("Properties Resource Location: " + resource.getURL());
		}
		if (resource != null && resource.getInputStream() != null) {
			properties.load(resource.getInputStream());
		}
	}
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:11,代码来源:ApplicationResourceLoader.java

示例13: readCertificate

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * Read certificate x 509 certificate.
 *
 * @param resource the resource
 * @return the x 509 certificate
 */
public static X509Certificate readCertificate(final Resource resource) {
    try (InputStream in = resource.getInputStream()) {
        return CertUtil.readCertificate(in);
    } catch (final Exception e) {
        throw new RuntimeException("Error reading certificate " + resource, e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:SamlUtils.java

示例14: getSigningCredential

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * getSigningCredential loads up an X509Credential from a file.
 *
 * @param resource the signing certificate file
 * @return an X509 credential
 */
private static Credential getSigningCredential(final Resource resource) {
    try(InputStream inputStream = resource.getInputStream()) {
        final CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
        final X509Certificate certificate = (X509Certificate) certificateFactory.generateCertificate(inputStream);
        final Credential publicCredential = new BasicX509Credential(certificate);
        LOGGER.debug("getSigningCredential: key retrieved.");
        return publicCredential;
    } catch (final Exception ex) {
        LOGGER.error(ex.getMessage(), ex);
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:19,代码来源:WsFederationConfiguration.java

示例15: addArcadeLevel

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private static void addArcadeLevel(Resource as, String group) {
	LevelDefinition def = null;
	try {
		def = new LevelDefinition(as.getInputStream(), ++LevelManager.arcadeNum);
	} catch (Exception e) {
		GameConf.GAME_LOGGER.error(e.getMessage());
		return;
	}
	if (!def.isSettingSet(SettingKey.GROUP)) {
		def.setSetting(SettingKey.GROUP, group);
	}
	LevelManager.addLevel(def, false);
}
 
开发者ID:rekit-group,项目名称:rekit-game,代码行数:14,代码来源:LevelManager.java


注:本文中的org.springframework.core.io.Resource.getInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。