String (Map<String, String> mapData) { StringBuilder stringData = new StringBuilder(); for (Map.Entry<String, String> me : mapData.entrySet()) { stringData.append(me.getKey()).append("=\"").append(me.getValue()).append("\" "); } // Remove last space, if we did any appending if (stringData.length() > 0) { stringData.setLength(stringData.length() - 1); } return stringData.toString(); }