title: Writer not working for json file using Gson ,json file is blank after code execution
body: <p>I'm trying to write json data to a json file.</p>
  
  <p>After code execution no errors are thrown but the .json file is empty.</p>
  
  <p>Please find below code and help on this</p>
  
  <pre><code>import java.io.BufferedWriter;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.List;
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import com.google.gson.JsonObject;
  
  public class Test {
      public static void main(String[] args) throws JSONException {
          try {
              List&lt;String&gt; foo = new ArrayList&lt;String&gt;();
              foo.add("1");
              foo.add("2");
              foo.add("3");
              System.out.println("values :: "+foo);
  
              Writer writer = new FileWriter("operatorList.json");
              Gson gson = new GsonBuilder().create();
              gson.toJson(foo, writer);
          }
          catch(Exception e) {
              e.printStackTrace();            
          }
      }   
  }
  </code></pre>