title: reading files recursively and storing them java
body: <pre><code>    public Vector readFiles(File Mydir) {
  
          Vector&lt;File&gt; vec = new Vector&lt;&gt;(10,10);  // to store the needed files
  
          for (File f: Mydir.listFiles()){
              if (!f.isDirectory()){
                  System.out.println("file found"+ f.getName());
                  vec.addElement(f);
  
                  // reads all the files in the directory recursively
              } else
                  readFiles(f);
          }
         // System.out.println("size of vec = " + vec.size());
          return vec;
      }
  </code></pre>
  
  <p>Hi I'm trying to read all txt and pdf files in a Directory and store them in a vector . but my vector only adds 4 of them as an element ! 
  I printed the files and they are all found but not added to the vec . thanks for your help</p>