title: Unable to write Json output into file in java
body: <p>I am trying to write simple JSON data into a file but seems my file is blank. It does not write anything. When I print output in java console then it shows me correct.</p>
  
  <pre><code>import org.json.simple.JSONObject;
  
  JSONObject obj = new JSONObject();
  
  obj.put("Phone Number:", "XXXXXXXXX");
  obj.put("Fname:", "Mike");
  obj.put("Lname:", "Miller");
  obj.put("Street:", "101");
  
  try {
      FileWriter file = new FileWriter("D:\\file1.json");
      file.write(obj.toJSONString());
  }
  catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>I saw similar code on the internet and SO as well. I am following same but still not sure why it is not writing output into a file.</p>