List of usage examples for java.util Properties load
public synchronized void load(InputStream inStream) throws IOException
From source file:fm.last.moji.integration.AbstractMojiIT.java
private static void initMoji() throws IOException { String env = System.getProperty("env", ""); if (!"".equals(env)) { env = "." + env; }// w ww .ja v a 2 s . co m Properties properties = new Properties(); properties.load(AbstractMojiIT.class.getResourceAsStream("/moji.properties" + env)); String hosts = properties.getProperty("moji.tracker.hosts"); String domain = properties.getProperty("moji.domain"); keyPrefix = properties.getProperty("test.moji.key.prefix"); storageClassA = properties.getProperty("test.moji.class.a"); storageClassB = properties.getProperty("test.moji.class.b"); moji = new SpringMojiBean(); moji.setAddressesCsv(hosts); moji.setDomain(domain); moji.initialise(); moji.setTestOnBorrow(true); }
From source file:io.fabric8.profiles.ProfilesHelpers.java
public static Properties readPropertiesFile(Path path) throws IOException { Properties properties = new Properties(); try (InputStream is = Files.newInputStream(path)) { properties.load(is); }//from w w w . jav a 2 s.co m return properties; }
From source file:com.jivesoftware.os.routing.bird.deployable.config.extractor.ConfigExtractor.java
private static Map<String, String> extractAndPublish(Set<Class<? extends Config>> serviceConfig, File defaultServiceConfigFile, String context, String instanceKey, String instanceVersion, HttpRequestHelper buildRequestHelper, String setPath) throws IOException { ConfigExtractor serviceConfigExtractor = new ConfigExtractor(new PropertyPrefix(), serviceConfig); serviceConfigExtractor.writeDefaultsToFile(defaultServiceConfigFile); Properties defaultProperties = createKeySortedProperties(); defaultProperties.load(new FileInputStream(defaultServiceConfigFile)); Map<String, String> config = new HashMap<>(); for (Map.Entry<Object, Object> entry : defaultProperties.entrySet()) { config.put(entry.getKey().toString(), entry.getValue().toString()); }/*from w w w.j a va 2s .c o m*/ DeployableConfig setDefaults = new DeployableConfig(context, instanceKey, instanceVersion, config); DeployableConfig setConfig = buildRequestHelper.executeRequest(setDefaults, setPath, DeployableConfig.class, null); if (setConfig == null) { System.out.println("Failed to publish default config for " + instanceKey); } return config; }
From source file:com.taksmind.karma.functions.scheduled.Log.java
public static void uploadFile() throws IOException { try {/*from w ww .j a v a2 s.c o m*/ logDirectory = new File("logs"); if (!logDirectory.isDirectory()) { logDirectory.mkdir(); } date = sdf.parse(sdf.format(new Date())).toString().replaceAll(" ", "") .replaceAll("[0-9]+:[0-9]+:[0-9]+CDT", ""); Properties properties = new Properties(); //creates configuration object properties.load(new FileInputStream(Main.configuration)); ftpServer = properties.getProperty("ftpServer"); ftpUser = properties.getProperty("ftpUser"); ftpPassword = properties.getProperty("ftpPassword"); client = new FTPClient(); client.connect(ftpServer); int reply = client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { client.disconnect(); System.err.println("FTP server refused connection."); } if (client.login(ftpUser, ftpPassword)) { client.enterLocalPassiveMode(); String localFile = logDirectory.getAbsolutePath() + "/" + date + ".log"; String remoteFile = "/downloads/logs/" + date + ".log"; if (Main.debug) { System.out.println(localFile); System.out.println(remoteFile); } FileInputStream fis = new FileInputStream(new File(localFile)); if (client.storeFile(remoteFile, fis)) { System.out.println("File uploaded successfully."); } else { System.err.println("Uploading file failed.."); } fis.close(); client.logout(); client.disconnect(); } else { System.out.println("Could not authenticate with FTP server.."); client.logout(); } } catch (ParseException e) { System.err.println("Error parsing log file"); e.printStackTrace(); } catch (SocketException e) { System.err.println("some exception happened."); e.printStackTrace(); } catch (IOException e) { System.err.println("can not open or upload file."); e.printStackTrace(); } finally { if (client.isConnected()) { client.disconnect(); } } }
From source file:com.sunchenbin.store.feilong.core.util.PropertiesUtil.java
/** * ?Properties./* w ww .ja v a 2s. co m*/ * * @param inputStream * inputStream * @return <ul> * <li>, {@link java.util.Properties#load(InputStream)}</li> * </ul> * @see java.util.Properties#load(InputStream) * @see "org.springframework.core.io.support.PropertiesLoaderUtils#loadProperties(Resource)" */ public static Properties getProperties(InputStream inputStream) { if (null == inputStream) { throw new NullPointerException("the inputStream is null or empty!"); } Properties properties = new Properties(); try { properties.load(inputStream); return properties; } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:es.sistedes.handle.generator.Conversor.java
/** * Loads the properties file containing the command strings * /*w w w. j av a 2 s . c om*/ * @param commands * The {@link Properties} containing the commands */ private static void configureCommands(Properties commands) { try { commands.load(CliLauncher.class.getResourceAsStream("commands.properties")); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.feilong.core.util.PropertiesUtil.java
/** * ?{@link Properties}./*from w w w . j a v a 2 s. co m*/ * * @param inputStream * inputStream * @return <code>inputStream</code> null, {@link NullPointerException}<br> * , {@link java.util.Properties#load(InputStream)} * @see java.util.Properties#load(InputStream) * @see "org.springframework.core.io.support.PropertiesLoaderUtils#loadProperties(Resource)" */ public static Properties getProperties(InputStream inputStream) { Validate.notNull(inputStream, "inputStream can't be null!"); Properties properties = new Properties(); try { properties.load(inputStream); return properties; } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.googlecode.jsendnsca.NagiosSettingsFactory.java
/** * Create {@link NagiosSettings} from a stream containing properties * * @param inputStream/*from w w w . j a va 2 s . c o m*/ * containing properties * @return the {@link NagiosSettings} * @throws IOException * thrown on IO issue accessing stream * @throws NagiosConfigurationException * thrown on invalid configuration values */ public static NagiosSettings createSettings(InputStream inputStream) throws IOException, NagiosConfigurationException { try { Properties properties = new Properties(); properties.load(inputStream); return createSettings(properties); } finally { IOUtils.closeQuietly(inputStream); } }
From source file:com.feilong.commons.core.configure.PropertiesUtil.java
/** * ?Properties./*from w w w . j a v a 2 s . c o m*/ * * @param inputStream * inputStream * @return <ul> * <li>, {@link java.util.Properties#load(InputStream)}</li> * </ul> * @throws NullPointerException * if null==inputStream * @throws UncheckedIOException * the unchecked io exception * @see java.util.Properties#load(InputStream) * @see "org.springframework.core.io.support.PropertiesLoaderUtils#loadProperties(Resource)" */ public static Properties getProperties(InputStream inputStream) throws NullPointerException, UncheckedIOException { if (null == inputStream) { throw new NullPointerException("the inputStream is null or empty!"); } Properties properties = new Properties(); try { properties.load(inputStream); return properties; } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.seovic.config.Configuration.java
private static Map<String, String> loadConfiguration() { Map<String, String> props = new HashMap<String, String>(); props.put(EXPRESSION_TYPE, DEFAULT_EXPRESSION_TYPE); props.put(EXTRACTOR_TYPE, DEFAULT_EXTRACTOR_TYPE); props.put(UPDATER_TYPE, DEFAULT_UPDATER_TYPE); props.put(CONDITION_TYPE, DEFAULT_CONDITION_TYPE); props.put(SCRIPT_LANGUAGE, DEFAULT_SCRIPT_LANGUAGE); props.put(SEQUENCE_GENERATOR_TYPE, DEFAULT_SEQUENCE_GENERATOR_TYPE); props.put(SEQUENCE_CACHE_NAME, DEFAULT_SEQUENCE_CACHE_NAME); try {// w ww . ja va 2 s. c o m Properties config = new Properties(); config.load(Configuration.class.getClassLoader().getResourceAsStream("coherence-tools.properties")); for (String propertyName : config.stringPropertyNames()) { props.put(propertyName, config.getProperty(propertyName)); } } catch (Exception e) { // should never happen, as default file is embedded within JAR s_log.warn("Configuration file coherence-tools.properties" + " is missing. Using hardcoded defaults: \n" + props); } return props; }