public static String replace(HashMap<String,String> string2replace, String filePath)
    {
        String outcome = "";
        String newFile = "";
        int count = 0;
        try
        {
            if (string2replace.isEmpty() || filePath.equals(""))
            {
                outcome = "The list for replacing or the file path cannot be null";
            }
            else
            {
                String newFilePath = filePath + "OP" ;
                //read file
                FileReader r = new FileReader(filePath);
                Scanner sRead = new Scanner(r);
                String temp="";
                Collection<String> check = string2replace.keySet();
                    
                while (sRead.hasNext())
                {
                    temp = sRead.nextLine();
                    for (String s : check)
                        if (temp.contains(s))
                        {
                            outcome+= "'"+ s + "' REPLACED WITH '" + string2replace.get(s) + "'\n";
                            temp = temp.replace(s, string2replace.get(s));                        
                            count++;
                        }
                    newFile+=temp + "\n";
                }
            
                File f = new File(newFilePath);
                FileWriter w = new FileWriter(f);
                w.write(newFile);    
                w.close();
                outcome +="\n--------------------------------------------------------------\n";
                outcome += "Replacements done in "+ count +" cases\n";
                outcome += "New File written at: " + newFilePath;
            } // else ends
            
        } catch (FileNotFoundException ex)
        {
            Logger.getLogger(replaceMultiple.class.getName()).log(Level.SEVERE, null, ex);
            outcome = "Error reading or Writing File at " + filePath + "\nMake Sure you have Read-Write premissions to the directory you are reading from !";
        }
        catch(Exception ex)
        {
            outcome = "Unexpected error occured: " + ex;        
        }
        finally
        {
            return outcome;
        }
        
    }// replace ends