java runtime getinputstream,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方法的20個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: load

​點讚 3

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

public void load() throws Exception {

if(client == null) {

return;

}

List 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,

示例2: PublicKeyspacePersistenceSettings

​點讚 3

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

​點讚 3

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,

示例4: getSettings

​點讚 3

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.

*

*

*

* @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,

示例5: loadPropertiesFromPaths

​點讚 3

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

private static Properties loadPropertiesFromPaths(ResourceLoader resourceLoader, List 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,

示例6: getKeyStore

​點讚 3

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,

示例7: loadFromApplicationConfig

​點讚 2

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,

示例8: getSigningCredential

​點讚 2

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,

示例9: loadProperties

​點讚 2

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

@Override

protected Properties loadProperties(Resource resource, String filename) throws IOException {

Map 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,

示例10: createManifestFrom

​點讚 2

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,

示例11: loadProperties

​點讚 2

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,

示例12: loadProperties

​點讚 2

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,

示例13: readCertificate

​點讚 2

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,

示例14: getSigningCredential

​點讚 2

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,

示例15: addArcadeLevel

​點讚 2

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,

示例16: openZipResource

​點讚 2

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

/**

* Open the given resource as a a ZipInputStream.

* @param resource resource

* @return ZipInputStream

*/

protected ZipInputStream openZipResource(Resource resource) {

try {

return new ZipInputStream(new BufferedInputStream(resource.getInputStream()));

} catch (IOException e) {

throw new IllegalMigrationStateException("Could not deploy zip resource for version tag " + resource.getFilename(), e);

}

}

開發者ID:satspeedy,項目名稱:camunda-migrator,代碼行數:13,

示例17: loadWords

​點讚 2

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

/**

* Load word from a file.

*

* @param file filename for file located in resource folder

* @return set of words

*/

private Set loadWords(String file) {

Set words = new HashSet<>();

try {

Resource resource = applicationContext.getResource("classpath:/" + file);

BufferedReader reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));

String word;

while ((word = reader.readLine()) != null) {

words.add(word);

}

} catch (IOException e) {

logger.error("Error reading from wordfile", e);

}

return words;

}

開發者ID:BakkerTom,項目名稱:happy-news,代碼行數:21,

示例18: addResourceToRepositoryConnection

​點讚 2

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

private void addResourceToRepositoryConnection(RepositoryConnection repositoryConnection,

Optional optionalPrefixesResource, Resource resource,

List streamList) {

final String extension = FilenameUtils.getExtension(resource.getFilename());

try {

final InputStream inputStreamWithEnv;

if (optionalPrefixesResource.isPresent()

&& !resource.getFilename().equals("_prefixes.trig")) {

try (SequenceInputStream resourceSequenceInputStream = new SequenceInputStream(

optionalPrefixesResource.get().getInputStream(), resource.getInputStream())) {

inputStreamWithEnv = new EnvironmentAwareResource(resourceSequenceInputStream,

environment).getInputStream();

}

} else {

inputStreamWithEnv =

new EnvironmentAwareResource(resource.getInputStream(), environment).getInputStream();

}

final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

ByteStreams.copy(inputStreamWithEnv, outputStream);

repositoryConnection.add(new ByteArrayInputStream(outputStream.toByteArray()), "#",

FileFormats.getFormat(extension));

streamList.add(new ByteArrayInputStream(outputStream.toByteArray()));

} catch (IOException ex) {

LOG.error("Configuration file %s could not be read.", resource.getFilename());

throw new ConfigurationException(

String.format("Configuration file could not be read.", resource.getFilename()));

}

}

開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:29,

示例19: getScriptInputStream

​點讚 2

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

/**

* Replaces the dialect placeholder in the script URL and attempts to find a file for

* it. If not found, the dialect hierarchy will be walked until a compatible script is

* found. This makes it possible to have scripts that are generic to all dialects.

*

* @return Returns an input stream onto the script, otherwise null

*/

private InputStream getScriptInputStream(Class> dialectClazz, String scriptUrl) throws Exception

{

Resource resource = getDialectResource(dialectClazz, scriptUrl);

if (resource == null)

{

throw new AlfrescoRuntimeException("Script [ " + scriptUrl + " ] can't be found for " + dialectClazz);

}

return resource.getInputStream();

}

開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:17,

示例20: getResourceInputStream

​點讚 1

import org.springframework.core.io.Resource; //導入方法依賴的package包/類

/**

* Retrieve the remote source's input stream to parse data.

*

* @param resource the resource

* @param entityId the entity id

* @return the input stream

* @throws IOException if stream cannot be read

*/

protected InputStream getResourceInputStream(final Resource resource, final String entityId) throws IOException {

LOGGER.debug("Locating metadata resource from input stream.");

if (!resource.exists() || !resource.isReadable()) {

throw new FileNotFoundException("Resource does not exist or is unreadable");

}

return resource.getInputStream();

}

開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:16,

注:本文中的org.springframework.core.io.Resource.getInputStream方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值