List of usage examples for java.util Properties Properties
public Properties()
From source file:org.lambdamatic.elasticsearch.BaseIntegrationTest.java
protected static Client client() { final InputStream portsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("ports.properties"); if (portsStream != null) { final Properties properties = new Properties(); try {//from ww w . j ava 2 s . c om properties.load(portsStream); } catch (IOException e) { fail("Failed to load port properties from file", e); } return Client.connectTo(new HttpHost("localhost", Integer.parseInt(properties.getProperty("es.9200")))); } return Client.connectTo(new HttpHost("localhost", 9200)); }
From source file:Main.java
/** * Returns properties for RA admin-object element *///from ww w . j a va 2 s .co m public static Properties raAdminProperties() { Properties params = new Properties(); //attributes params.put("use-java-context", "true"); params.put("class-name", "Class3"); params.put("jndi-name", "java:jboss/Name3"); params.put("enabled", "true"); return params; }
From source file:Main.java
/** * Returns common properties for resource-adapter element *///ww w. ja va2s. co m public static Properties raCommonProperties() { Properties params = new Properties(); params.put("archive", "some.rar"); params.put("transaction-support", "XATransaction"); params.put("bootstrap-context", "default"); return params; }
From source file:Main.java
/** * Returns properties for RA admin-object element //w w w.j av a 2 s . co m */ public static Properties raAdminProperties() { Properties params = new Properties(); //attributes params.put("use-java-context", "false"); params.put("class-name", "Class3"); params.put("jndi-name", "java:jboss/Name3"); params.put("enabled", "true"); return params; }
From source file:com.leosys.core.utils.HttpServiceImpl.java
public static String getMyitem(String letter, Integer page) { Properties p = new Properties(); String urls = getXmlPath();//from w w w. ja v a 2 s . c om try { p.load(new FileInputStream(urls)); } catch (Exception e) { e.printStackTrace(); } String subUrl = p.getProperty("path"); String restUrl = subUrl + "model=myservice&action=getwebdomainsitebypage&page=" + page + "&pagesize=10"; if (StringUtils.isNotEmpty(letter)) { restUrl += "&letter=" + letter; } StringBuffer strBuf; strBuf = new StringBuffer(); try { URL url = new URL(restUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));//? String line = null; while ((line = reader.readLine()) != null) strBuf.append(line + " "); reader.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(strBuf.toString()); return strBuf.toString(); }
From source file:Main.java
public static Properties loadPropertyInstance(String filePath, String fileName) { try {//www . j ava 2s. c om File d = new File(filePath); if (!d.exists()) { d.mkdirs(); } File f = new File(d, fileName); if (!f.exists()) { f.createNewFile(); } Properties p = new Properties(); InputStream is = new FileInputStream(f); p.load(is); is.close(); return p; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:ezbake.crypto.utils.TestExternalHttps.java
private static HttpClient getSSLHttpClient() { HttpClient httpClient;//from w ww . j av a2s. c o m Properties serverProps = new Properties(); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_CERTIFICATES_DIRECTORY, "src/test/resources"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_SECURITY_ID, "appId"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_APPLICATION_KEYSTORE_FILE, "keystore.jks"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_APPLICATION_KEYSTORE_TYPE, "JKS"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_APPLICATION_KEYSTORE_PASS, "password"); try { httpClient = HttpClients.custom().setSslcontext(EzSSL.getSSLContext(serverProps)).build(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("IO Exception reading keystore/truststore file: " + e.getMessage()); } return httpClient; }
From source file:com.github.sparkfy.util.Log4jPropertyHelper.java
public static void updateLog4jConfiguration(/*Class<?> targetClass,*/ String log4jPath) throws Exception { Properties customProperties = new Properties(); FileInputStream fs = null;/*from www.j a v a2 s .c om*/ InputStream is = null; try { fs = new FileInputStream(log4jPath); // is = targetClass.getResourceAsStream("/log4j.properties"); is = Utils.getClassLoader().getResourceAsStream("com/github/sparkfy/log4j-defaults.properties"); customProperties.load(fs); Properties originalProperties = new Properties(); originalProperties.load(is); for (Entry<Object, Object> entry : customProperties.entrySet()) { originalProperties.setProperty(entry.getKey().toString(), entry.getValue().toString()); } LogManager.resetConfiguration(); PropertyConfigurator.configure(originalProperties); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(fs); } }
From source file:com.antonjohansson.elasticsearchshell.utils.PropertiesUtils.java
/** * Reads properties from the given file. *///from w w w .ja v a 2 s. c om public static Properties read(File file) { InputStream input = null; try { input = new FileInputStream(file); Properties properties = new Properties(); properties.load(input); return properties; } catch (Exception e) { throw new RuntimeException(e); } finally { closeQuietly(input); } }
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 . jav a 2s. 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()); } }