title: How to create txt file from runnable jar?
body: <p>In the following code, I first created a <code>File</code> in the root directory and then <code>write</code> string into it. Then I read data from that <code>File</code>:</p>
  
  <pre><code>        File file = new File("myfile.txt");
              if(!file.exists()){
                  file.createNewFile();
                  FileWriter fw = new FileWriter(file.getAbsoluteFile());
                  BufferedWriter bw = new BufferedWriter(fw);
                  bw.write(com_port_hardcoded);
                  bw.close();
              }
              Scanner scn = new Scanner(file);
              comPort = scn.nextLine().trim();
              scn.close();
  </code></pre>
  
  <p>Now, when I compile and run this code in eclipse, it works perfectly. But when I export a 'runnable jar' of this code, the <code>txt</code> file is not there in the folder of the jar.</p>
  
  <p>I don't know where the <code>txt</code> file is generated or if it is generated at all.</p>