List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:Main.java
/** * This isn't what the RI does. The RI doesn't have hard-coded defaults, so * supplying your own "content.types.user.table" means you don't get any of * the built-ins, and the built-ins come from * "$JAVA_HOME/lib/content-types.properties". *//*from ww w . j av a2 s. c o m*/ private static void applyOverrides() { // Get the appropriate InputStream to read overrides from, if any. InputStream stream = getContentTypesPropertiesStream(); if (stream == null) { return; } try { try { // Read the properties file... Properties overrides = new Properties(); overrides.load(stream); // And translate its mapping to ours... for (Map.Entry<Object, Object> entry : overrides.entrySet()) { String extension = (String) entry.getKey(); String mimeType = (String) entry.getValue(); add(mimeType, extension); } } finally { stream.close(); } } catch (IOException ignored) { } }
From source file:com.sosee.util.PropertyUtil.java
public static String readValue(String key) { Properties props = new Properties(); try {/*from w ww .j ava 2s.c o m*/ InputStream in = new BufferedInputStream(new FileInputStream(getFilePath())); props.load(in); String value = props.getProperty(key); return value == null ? "" : value; } catch (Exception e) { return ""; } }
From source file:hudson.plugins.blazemeter.utils.Utils.java
public static String version() { Properties props = new Properties(); try {/*from w w w. ja v a 2 s . co m*/ props.load(Utils.class.getResourceAsStream("/version.properties")); } catch (IOException ex) { props.setProperty(Constants.VERSION, "N/A"); } return props.getProperty(Constants.VERSION); }
From source file:com.axiomine.largecollections.utilities.KryoUtils.java
public static void registerDefaultKryoClasses(Kryo kryo) throws Exception { final Properties props = new Properties(); props.load(KryoUtils.class.getClassLoader().getResourceAsStream("KryoRegistration.properties")); Set ks = props.keySet();//from w w w . j a v a2 s .c o m for (Object k : ks) { // System.out.println(k); Class c = Class.forName((String) k); Class s = Class.forName(props.getProperty((String) k)); kryo.register(c, (Serializer) s.newInstance()); } }
From source file:playground.app.Application.java
public static HttpHandler createHttpHandler() throws IOException { Properties prop = new Properties(); prop.load(Application.class.getClassLoader().getResourceAsStream("application.properties")); String profiles = prop.getProperty("profiles"); if (profiles != null) { System.setProperty("spring.profiles.active", profiles); }//from w w w .j a v a 2s . c om AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("playground"); DispatcherHandler dispatcherHandler = new DispatcherHandler(); dispatcherHandler.setApplicationContext(context); Map<String, WebFilter> beanNameToFilters = context.getBeansOfType(WebFilter.class); WebFilter[] filters = beanNameToFilters.values().toArray(new WebFilter[0]); Arrays.sort(filters, AnnotationAwareOrderComparator.INSTANCE); return WebHttpHandlerBuilder.webHandler(dispatcherHandler) .exceptionHandlers(new ResponseStatusExceptionHandler()).filters(filters).build(); }
From source file:com.ms.commons.utilities.StaticContentDeploy.java
private static String getPropertyFromFile(File propertyFile, String property) { FileInputStream inputStream = null; InputStreamReader reader = null; try {/*w w w. j a v a2 s. c o m*/ inputStream = new FileInputStream(propertyFile); reader = new InputStreamReader(inputStream, "utf-8"); Properties properties = new Properties(); properties.load(reader); return properties.getProperty(property, StringUtils.EMPTY); } catch (Exception e) { logger.error("StaticContentDeploy init failed", e); } finally { closeQuietly(inputStream, reader); } return StringUtils.EMPTY; }
From source file:net.jcreate.e3.table.skin.processor.VelocityHelper.java
public static Properties getDefaultProperties() throws InitVelocityEngineException { InputStream is = VelocityHelper.class.getResourceAsStream("Velocity.properties"); Properties props = new Properties(); try {/* ww w. j a v a 2 s.com*/ props.load(is); } catch (IOException e) { e.printStackTrace(); final String MSG = "!" + e.getMessage(); if (log.isErrorEnabled()) { log.error("!" + e.getMessage()); } throw new InitVelocityEngineException(MSG, e); } return props; }
From source file:Main.java
private static Properties loadPropties(Context context, String file) throws IOException { Properties properties = new Properties(); try {/* w ww . ja v a 2 s . c om*/ InputStream fileStream = context.getAssets().open(file); properties.load(fileStream); fileStream.close(); } catch (FileNotFoundException e) { } return properties; }
From source file:com.mgmtp.perfload.core.common.util.PropertiesUtils.java
/** * Loads properties as map from the specified reader. This method delegates to * {@link Properties#load(Reader)}./*from ww w.j a v a2s . co m*/ * * @return the map */ public static PropertiesMap loadProperties(final Reader reader) throws IOException { Properties props = new Properties(); props.load(reader); return PropertiesMap.fromProperties(props); }
From source file:com.microsoft.windowsazure.services.core.Configuration.java
public static Configuration load() throws IOException { Configuration config = new Configuration(); InputStream stream = Configuration.class.getClassLoader() .getResourceAsStream("META-INF/com.microsoft.windowsazure.properties"); if (stream != null) { Properties properties = new Properties(); properties.load(stream); for (Object key : properties.keySet()) { config.setProperty(key.toString(), properties.get(key)); }//from ww w . j av a 2 s . c o m } return config; }