Here you can find the source of hashMapToString(HashMap
Parameter | Description |
---|---|
map | a parameter |
public static String hashMapToString(HashMap<String, ?> map)
//package com.java2s; /**/*from ww w .ja va2s.c o m*/ * Copyright (c) 2009 University of Rochester * * This program is free software; you can redistribute it and/or modify it under the terms of the MIT/X11 license. The text of the * license can be found at http://www.opensource.org/licenses/mit-license.php and copy of the license can be found on the project * website http://www.extensiblecatalog.org/. * */ import java.util.HashMap; import java.util.Map; public class Main { /** Create a string representation of hash map as * key="value" key="value" ... * @param map * @return */ public static String hashMapToString(HashMap<String, ?> map) { StringBuffer text = new StringBuffer(); boolean isFirst = true; for (Map.Entry<String, ?> e : map.entrySet()) { if (!isFirst) text.append(' '); text.append(e.getKey()).append("=\"").append(e.getValue().toString()).append('"'); isFirst = false; } return text.toString(); } }