當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。