public void writeMappedSystem( ConnectionConfigDTO configDataDTO, String applicationHome, String jsonString) throws AppException { String fileLocation = null; String workingDir = System.getProperty("user.dir"); applicationHome = workingDir + File.separator + APPDATABASEFOLDER; String tenentId = configDataDTO.getTenantID(); String dirLocation = null; FileWriter fstream = null; BufferedWriter out = null; try { dirLocation = applicationHome + File.separator + tenentId; System.out.println(dirLocation); fileLocation = dirLocation + File.separator + configDataDTO.getConnectionId() + ".map"; File file = new File(fileLocation); if (!file.exists()) { file.createNewFile(); } fstream = new FileWriter(file.getAbsoluteFile()); out = new BufferedWriter(fstream); int count = 0; // create your iterator for your map Iterator<Entry<String, String>> it = configDataDTO.getLocAndRemoteFieldMap().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> pairs = it.next(); System.out.println("Value is " + pairs.getValue()); out.write(pairs.getKey() + "=" + pairs.getValue() + "\n"); } } catch (IOException e) { e.printStackTrace(); throw new AppException("Could Not Store Data at Location " + fileLocation); } catch (Exception e) { e.printStackTrace(); throw new AppException("Could Not Store Data at Location " + fileLocation); } finally { try { if (out != null) { out.close(); } if (fstream != null) { fstream.close(); } } catch (Exception e) { } } }