public static void copyPropertiesToMap ( Properties source , Map < String , String > target ) { if ( source != null ) { //convert to map Iterator < Entry < Object , Object > > iterator = source . entrySet ( ) . iterator ( ) ; Entry < Object , Object > entry = null ; String key = null ; String value = null ; while ( iterator . hasNext ( ) ) { //get next entry entry = iterator . next ( ) ; //get next key/value key = ( String ) entry . getKey ( ) ; value = ( String ) entry . getValue ( ) ; //put in map target . put ( key , value ) ; } } }
This function copies all mappings from source properties to target map .