Here you can find the source of copyMapWithoutEmpties(Map extends Object, ? extends Object> original)
public static Map<Object, Object> copyMapWithoutEmpties(Map<? extends Object, ? extends Object> original)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import java.util.Set; public class Main { public static Map<Object, Object> copyMapWithoutEmpties(Map<? extends Object, ? extends Object> original) { Map<Object, Object> result = new HashMap<Object, Object>(); Set<?> keys = original.keySet(); for (Object key : keys) { Object value = original.get(key); if (value == null || value.toString().length() < 1) continue; result.put(key, value);// ww w.j a va 2 s .c om } return result; } }