title: how to open all files in a directory in java, read them, creat new files, write to them
body: <p>I am sorry I dont have a code, I say in a few answers how to make a file and write to it, but I have another question.
  I give a path to a folder in my compilation, and I want for each file that ends with a .jack to create the same file name that ends with .xml</p>
  
  <p>and open the xml file and write to it.
  exemple:</p>
  
  <pre><code>start.jack
  bet.jack
  =&gt;
  start.xml
  bet.xml
  </code></pre>
  
  <p>and in each xml file I would like to write stuff according whats written in the jack file.</p>
  
  <p>so actually I need to open the jack file, read from it, and then write to the xml file itself.</p>
  
  <p>I hope I explained myself correctly.</p>
  
  <p><strong>My Code:</strong></p>
  
  <pre><code>public String readFile(String filename)
  {
     String content = null;
     File file = new File(filename);
     try {
         FileReader reader = new FileReader(file);
         char[] chars = new char[(int) file.length()];
         reader.read(chars);
         content = new String(chars);
         reader.close();
     } catch (IOException e) {
         e.printStackTrace();
     }
     return content;
  }
  </code></pre>
  
  <p>I took this lines from stackoverflow, and it worked perfectly</p>