Java Properties Get getIntersectionOfPropertyValues(Properties propertyFileOne, Properties propertyFileTwo)

Here you can find the source of getIntersectionOfPropertyValues(Properties propertyFileOne, Properties propertyFileTwo)

Description

get Intersection Of Property Values

License

Apache License

Declaration

public static Map<String, String> getIntersectionOfPropertyValues(Properties propertyFileOne,
            Properties propertyFileTwo) 

Method Source Code


//package com.java2s;
/*//from w w w.  ja v  a  2 s . co  m
 *  Inspired by the Commons Collections package created by Apache
 *  http://commons.apache.org/collections/
 *  http://www.apache.org/licenses/LICENSE-2.0
 */

import java.util.*;

public class Main {
    public static Map<String, String> getIntersectionOfPropertyValues(Properties propertyFileOne,
            Properties propertyFileTwo) {
        Map<String, String> intersection = new HashMap<String, String>();

        for (String key : propertyFileOne.stringPropertyNames()) {
            String propertyOneValue = propertyFileOne.getProperty(key);
            String propertyTwoValue = propertyFileTwo.getProperty(key);
            if (propertyOneValue != null && propertyTwoValue != null && propertyOneValue.equals(propertyTwoValue)) {
                intersection.put(key, propertyOneValue);
            }
        }

        return intersection;
    }
}

Related

  1. copyProperties(Hashtable src, Hashtable target)
  2. getBoolean(Properties props, String key)
  3. getBoolean(Properties props, String name, boolean defaultValue)
  4. getInt(Properties props, String name)
  5. getInt(Properties props, String name, int defaultValue)
  6. getIntInRange(Properties props, String name, int defaultValue, int min, int max)
  7. getIntProperty(Properties props, String keyword, int defaultValue)
  8. getIsB37PropertyValue(final Properties dataSourceProperties)
  9. getLocalizedProperties(String[] propertyKeys, Properties properties)