title: Writing String Data to a file (Overwrite if already exists and create new if not exists)
body: <p>I want to write the content of a string variable say $data</p>
  
  <p>in to a file named data.xml
  the folder location will vary depends upon the content of $appId variable</p>
  
  <p>like i want to write file in </p>
  
  <pre><code>  files_dir/$appId/data.xml
  </code></pre>
  
  <p>moreover if that file already exists than i want to rewrite otherwise i want to create the folder 
  and then create the file data.xml</p>
  
  <p>Can u suggest some way to do so.</p>