PostEncoder { @SuppressWarnings( "deprecation" ) public static String encode(Map<String,?> map ) { StringBuilder buff = new StringBuilder(); for (Map.Entry<String, ?> entry : map.entrySet()) { if ( buff.length() != 0 ) buff.append( "&" ); buff.append( entry.getKey() ); buff.append( "=" ); buff.append( URLEncoder.encode(entry.getValue().toString(), Charsets.UTF_8) ); } return buff.toString(); }  @SuppressWarnings( "deprecation" ) static String encode(Map<String,?> map ); static String encode(ImmutableMultimap<String,?> map);  }
@Test public void testEncodeMultimap() throws Exception { ImmutableMultimap<String,String> multimap = ImmutableMultimap.of("animal", "cat", "animal", "dog"); String encoded = PostEncoder.encode(multimap); Assert.assertEquals("animal=cat&animal=dog", encoded); }