title: How to create a file using java in a webapp?
body: <p>I am trying to make a webapps which creates a file in a specific folder. This app should work both on windows and ubuntu but they have different file structures. So how do I mention path in creation of file and again in Ubuntu I also need to use permissions. How can I give permissions to the folder in which I am trying to create a file. I am using java for this and this is my code:</p>
  
  <pre><code> //bfr=new BufferedReader(new InputStreamReader(System.in));
   String fileName="/home/hemant/"+credentials[3];
   String content=String.valueOf(n)+"\n"+messages.length;
   File file=new File(fileName);       
   if(!file.exists()){
        System.out.println("filecreated");
        file.createNewFile();
   }   
  </code></pre>
  
  <p>my app is a tomcat based app. What should I do? I am new to this and don't have any idea.</p>