Code example for StringTokenizer

Methods: countTokens, nextToken

0
        } 
        return obj;
    } 
 
    public static Object parseColor(String value) {
        final StringTokenizer st = new StringTokenizer(value, ",", false);
        final int count = st.countTokens();
        try { 
            if (count == 1) {
                return Color.decode(value);
            } else if (count == 3 || count == EOS_SEEN) {
                final int r = Integer.parseInt(st.nextToken());
                final int g = Integer.parseInt(st.nextToken());
                final int b = Integer.parseInt(st.nextToken());
                final int a = count == EOS_SEEN ? Integer.parseInt(st.nextToken()) : 255;
                try { 
                    return new Color(r, g, b, a);
                } catch (IllegalArgumentException e) {
                    return null; 
                } 
            } else {