List of usage examples for java.util Properties Properties
public Properties()
From source file:Main.java
public static void output(Document doc, OutputStream outputStream) throws Exception { TransformerFactory tFactory = TransformerFactory.newInstance(); tFactory.setAttribute("indent-number", 4); Transformer transformer = tFactory.newTransformer(); Properties outputProperties = new Properties(); outputProperties.put(OutputKeys.INDENT, "yes"); outputProperties.put("{http://xml.apache.org/xslt}indent-amount", "4"); transformer.setOutputProperties(outputProperties); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new OutputStreamWriter(outputStream, "UTF-8")); transformer.transform(source, result); }
From source file:Main.java
public static Properties getBuildProperties() { synchronized (sBuildPropertiesLock) { if (sBuildProperties == null) { sBuildProperties = new Properties(); try { sBuildProperties.load(new FileInputStream(BUILD_PROP_FILE)); } catch (IOException e) { e.printStackTrace();/*from w w w. ja v a2 s .com*/ } } } return sBuildProperties; }
From source file:Main.java
/** Read a properties file from /assets. Returns null if it does not exist. */ public static Properties getProperties(String name, Context context) { Resources resources = context.getResources(); AssetManager assetManager = resources.getAssets(); // Read from the /assets directory try {// ww w . j a v a 2 s . c o m InputStream inputStream = assetManager.open(name); Properties properties = new Properties(); properties.load(inputStream); return properties; } catch (IOException e) { Log.i("ChatSecure", "no chatsecure.properties available"); return null; } }
From source file:Main.java
private static Properties getBuildProperties() { synchronized (sBuildPropertiesLock) { if (sBuildProperties == null) { sBuildProperties = new Properties(); try { sBuildProperties.load(new FileInputStream(BUILD_PROP_FILE)); } catch (IOException e) { e.printStackTrace();/* w ww.j a v a2 s. co m*/ } } } return sBuildProperties; }
From source file:Main.java
public static String readData(Context mContext, String key, int resId) { Properties props = new Properties(); try {/*from ww w. j a v a 2 s .c om*/ InputStream in = new BufferedInputStream(mContext.getResources().openRawResource(resId)); props.load(in); in.close(); String value = props.getProperty(key); return value; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:framework.clss.ConnectionBD.java
/** * Open conection with Data Base//from w ww. ja v a2 s. co m * */ public static void inicializa_BasicDataSourceFactory() { Properties propiedades = new Properties(); /* setMaxActive(): N mx de conexiones que se pueden abrir simultneamente. setMinIdle(): N mn de conexiones inactivas que queremos que haya. Si el n de conexiones baja de este n, se abriran ms. setMaxIdle(): N mx de conexiones inactivas que queremos que haya. Si hay ms, se irn cerrando. */ propiedades.setProperty("driverClassName", "com.mysql.jdbc.Driver"); propiedades.setProperty("url", "jdbc:mysql://localhost:3306/mysql"); propiedades.setProperty("maxActive", "10"); propiedades.setProperty("maxIdle", "8"); propiedades.setProperty("minIdle", "0"); propiedades.setProperty("maxWait", "500"); propiedades.setProperty("initialSize", "5"); propiedades.setProperty("defaultAutoCommit", "true"); propiedades.setProperty("username", "root"); propiedades.setProperty("password", ""); propiedades.setProperty("validationQuery", "select 1"); propiedades.setProperty("validationQueryTimeout", "100"); propiedades.setProperty("initConnectionSqls", "SELECT 1;SELECT 2"); propiedades.setProperty("poolPreparedStatements", "true"); propiedades.setProperty("maxOpenPreparedStatements", "10"); try { //propiedades.load(new FileInputStream("src/config/datasource_config.properties")); dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(propiedades); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.toString()); } }
From source file:Main.java
/** * Find element in XML document with given property * @param doc XML document/*w ww . ja v a 2 s . c o m*/ * @param tagName Tag name * @param propName Property name * @param propValue Property value * @return Element or null if not found */ public static Element findElement(Document doc, String tagName, String propName, String propValue) { Properties props = new Properties(); props.put(propName, propValue); return findElement(doc, tagName, props); }
From source file:Main.java
public static Document parseFile(final File aFile) throws SAXException, ParserConfigurationException { Properties props;// w w w. j a v a 2s. co m props = new Properties(); return parseFile(aFile, props); }
From source file:Main.java
/** * Create a MimeMessage using the parameters provided. * * @param to Email address of the receiver. * @param from Email address of the sender, the mailbox account. * @param subject Subject of the email.// w ww . java 2 s . c om * @param bodyText Body text of the email. * @return MimeMessage to be used to send email. * @throws MessagingException */ public static MimeMessage createEmail(String to, String from, String subject, String bodyText) throws MessagingException { Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); MimeMessage email = new MimeMessage(session); email.setFrom(new InternetAddress(from)); email.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(to)); email.setSubject(subject); email.setText(bodyText); return email; }
From source file:Main.java
/** * Gets properties from Assets/* w w w. j a v a 2 s. c om*/ * * @param name Properties file * @param context Context * @return Properties */ public static Properties getProperties(String name, Context context) { Resources resources = context.getResources(); AssetManager assetManager = resources.getAssets(); Properties properties = null; // Read from the /assets directory try { InputStream inputStream = assetManager.open(name); properties = new Properties(); properties.load(inputStream); } catch (IOException e) { e.printStackTrace(); } return properties; }