title: Create a file in tomcat
body: <p>I hava a tomcat java web application. I want to create a file to store some json data in it. How do I create this file and where will this file be created?</p>
  
  <pre><code>public void insert(UserProfile profile) {
      JSONObject jsUser = profile.asJSONObject();     
  
      try {
  
          String path = profile.getUsername()+".json";
          FileWriter fileWriter = new FileWriter(path);
  
          fileWriter.write(jsUser.toJSONString());
          fileWriter.flush();
          fileWriter.close();
  
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>