Java Properties Parse parsePropertiesString(String s)

Here you can find the source of parsePropertiesString(String s)

Description

Parse the semi-colon delimited string of name=value properties.

License

Open Source License

Parameter

Parameter Description
s Semi-colon delimited name=value string

Return

properties

Declaration

public static Hashtable parsePropertiesString(String s) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    /**/*from ww w .j a  v  a2s.c om*/
     * Parse the semi-colon delimited string of name=value properties.
     *
     * @param s Semi-colon delimited name=value string
     * @return properties
     */
    public static Hashtable parsePropertiesString(String s) {
        Hashtable properties = new Hashtable();
        if (s != null) {
            StringTokenizer tok = new StringTokenizer(s, ";");
            while (tok.hasMoreTokens()) {
                String nameValue = tok.nextToken();
                int idx = nameValue.indexOf("=");
                if (idx < 0) {
                    continue;
                }
                properties.put(nameValue.substring(0, idx).trim(),
                        nameValue.substring(idx + 1));
            }
        }
        return properties;
    }
}

Related

  1. parseBooleanProperty(Properties props, String keyword, boolean defaultValue)
  2. parseHtmlProperties(String s)
  3. parseProperties(final String string)
  4. parseProps(Properties p)