本文整理汇总了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();
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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());
}
}
}
示例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);
}
}
示例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;
}
示例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);
}