Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; public class Main { public static <K> Map<K, String> trimMapValue(Map<K, String> map) { Map<K, String> covertedResult = new HashMap<K, String>(map.size()); Set<Entry<K, String>> entrySet = map.entrySet(); for (Entry<K, String> entry : entrySet) { covertedResult.put(entry.getKey(), entry.getValue().trim()); } return covertedResult; } }