Example usage for java.util Properties put

List of usage examples for java.util Properties put

Introduction

In this page you can find the example usage for java.util Properties put.

Prototype

@Override
    public synchronized Object put(Object key, Object value) 

Source Link

Usage

From source file:Main.java

public static void saveAccount(Activity act, String account, String psw) {
    String str = account + "," + psw;
    Properties localProperties = new Properties();
    localProperties.put("account", str);
    try {//from ww w  .ja  v  a  2s  . c  om
        File file = new File(act.getFilesDir() + "/accout.cfg");
        if (!file.exists())
            file.createNewFile();
        FileOutputStream localFileOutputStream = act.openFileOutput("account.cfg", Context.MODE_PRIVATE);
        localProperties.store(localFileOutputStream, "");
        localFileOutputStream.close();
    } catch (Exception localException) {
        localException.printStackTrace();
    }
}

From source file:TestCreateConnectionWithProperties_MySQL.java

public static Connection getConnection() throws Exception {
    String driver = "org.gjt.mm.mysql.Driver";
    // load the driver
    Class.forName(driver);// ww w  .  ja  v a 2 s  .  c  om
    String dbURL = "jdbc:mysql://localhost/databaseName";
    String dbUsername = "root";
    String dbPassword = "root";

    java.util.Properties connProperties = new java.util.Properties();
    connProperties.put(DATABASE_USER, dbUsername);
    connProperties.put(DATABASE_PASSWORD, dbPassword);

    // set additional connection properties:
    // if connection stales, then make automatically
    // reconnect; make it alive again;
    // if connection stales, then try for reconnection;
    connProperties.put(MYSQL_AUTO_RECONNECT, "true");
    connProperties.put(MYSQL_MAX_RECONNECTS, "4");
    Connection conn = DriverManager.getConnection(dbURL, connProperties);
    return conn;
}

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

/**
 * (android) write to file/*from   w  ww. ja  v a  2s  .  c  o m*/
 * 
 * @param fileName
 * @param toSave
 * @return
 */
public static boolean androidFileSave(Context con, String fileName, String toSave) {
    Properties properties = new Properties();
    properties.put(FILE_ENCODING, toSave);
    try {
        FileOutputStream stream = con.openFileOutput(fileName, Context.MODE_WORLD_WRITEABLE);
        properties.store(stream, "");
    } catch (FileNotFoundException e) {
        return false;
    } catch (IOException e) {
        return false;
    }

    return true;
}

From source file:Main.java

/**
 * Reset all error flags to 0./*from w w  w  .j  a  v  a  2s . c o m*/
 */
public static void resetErrorFlags() {
    Log.i(TAG, "Reset all error flags.");

    Properties prop = new Properties();

    prop.put(ILLEGAL_STATE_ERROR, "0");
    prop.put(ILLEGAL_ARGUMENT_ERROR, "0");
    prop.put(INSTANTIATION_ERROR, "0");

    saveConfig(prop);
}

From source file:bbejeck.streams.twitter.TwitterStreamsAnalyzer.java

private static Properties getProperties() {
    Properties props = new Properties();
    props.put(StreamsConfig.CLIENT_ID_CONFIG, "Twitter-Streams-Analysis");
    props.put("group.id", "twitter-streams");
    props.put(StreamsConfig.APPLICATION_ID_CONFIG, "twitter-streams-id");
    props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
    props.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, "localhost:2181");
    props.put(StreamsConfig.REPLICATION_FACTOR_CONFIG, 1);
    props.put(StreamsConfig.TIMESTAMP_EXTRACTOR_CLASS_CONFIG, WallclockTimestampExtractor.class);
    return props;
}

From source file:com.stratio.decision.executables.DataFlowFromCsvMain.java

private static ProducerConfig createProducerConfig(String brokerList) {
    Properties properties = new Properties();
    properties.put("serializer.class", "kafka.serializer.StringEncoder");
    properties.put("metadata.broker.list", brokerList);
    return new ProducerConfig(properties);
}

From source file:Main.java

/**
 * Find element in XML document with given property
 * @param doc XML document/* ww  w.j a v a 2s.  co 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:com.threepillar.labs.meeting.Main.java

public static void sendEmailInvite() throws Exception {

    // set the properties to send email
    Properties props = new Properties();
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.socketFactory.port", "465");
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.port", "465");

    props.put("username", "");
    props.put("password", "");

    // set the organizer of the event
    Participant from = new Participant("From", "from@from.com", ParticipantType.REQUIRED);

    // set the attendees of the event
    Participant attendee1 = new Participant("Attendee1", "attendee1@attendee.com", ParticipantType.REQUIRED);
    List<Participant> list = new ArrayList<Participant>();
    list.add(attendee1);/*from   w  ww .j a  v  a  2  s.c o  m*/
    Invite invite = new EmailInviteImpl(props);
    Date startDate = new Date(System.currentTimeMillis() + 600000);
    Date endDate = new Date(startDate.getTime() + 1800000);
    invite.sendInvite("Testing Event", "Testing dummy event", from, list, startDate, endDate, "Delhi");
}

From source file:Main.java

/**
 * Returns properties for RA admin-object element
 *///  w ww  .j av a 2 s .  c  o 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;
}