All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.objectweb.celtix.tools.utils.PropertyUtil Maven / Gradle / Ivy

The newest version!
package org.objectweb.celtix.tools.utils;

import java.io.*;
import java.util.*;
import org.objectweb.celtix.common.util.StringUtils;

public class PropertyUtil {
    private static final String DEFAULT_DELIM = "=";
    private Map  maps = new HashMap();

    public void load(InputStream is, String delim) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();
        while (!StringUtils.isEmpty(line)) {
            StringTokenizer st = new StringTokenizer(line, delim);
            String key = null;
            String value = null;
            if (st.hasMoreTokens()) {
                key  = st.nextToken().trim();
            }
            if (st.hasMoreTokens()) {
                value = st.nextToken().trim();
            }

            maps.put(key, value);

            line = br.readLine();
        }
        br.close();
    }
    
    public void load(InputStream is) throws IOException {
        load(is, DEFAULT_DELIM);
    }
    
    public String getProperty(String key) {
        return this.maps.get(key);
    }

    public Map getMaps() {
        return this.maps;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy