Convert map to String
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class Main {
public static final String mapToString( Map map )
{
if ( ( map == null ) || ( map.size() == 0 ) )
{
return "";
}
StringBuffer sb = new StringBuffer();
boolean isFirst = true;
Iterator iter = map.keySet().iterator();
while ( iter.hasNext() )
{
if ( isFirst )
{
isFirst = false;
}
else
{
sb.append( ", " );
}
Object key = iter.next();
sb.append( key );
sb.append( " = '" ).append( map.get( key ) ).append( "'" );
}
return sb.toString();
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
Collection Map:
- Convert map to String
- Convert a map to a synchronized Map
- Get a key from value with a Map
- Get a set view of Keys from Map
- Get Size of a Map
- Get entry set from map
- Get Keys stored in an array from a map
- Get Values in an array from a map
- Is a particular key exists in Map
- Is a particular value exists in the Map
- Iterate the key value pair in a Map
- Iterate through the values of a Map
- Iterate both the keys and values of a map
- Remove by key from a Map
- Remove all values from Map