title: Convert an array of file path to array of files and calculate the size of each
body: <p>I have a <code>JTextField</code> in which the user has to enter file path separated by comma  </p>
  
  <p>I take the text field value into an array:  </p>
  
  <pre><code>String[] filename = filename.split(","); // where filename is the jtextfield value
  </code></pre>
  
  <p>I need to check the size of each file in the array.</p>
  
  <p>If the file size is more than 10 MB, I need to inform the user.  </p>
  
  <p>How to convert an array of file path to array of files and calculate the file size of each file in Java?</p>
  
  <p>I tried using :</p>
  
  <pre><code>File[] files = new File[filename.length];    
  
  for(int i=0;i &lt; filename.length;i++){    
      long filesizeinbytes=files[i].length;    
      long filesizeinkb= filesizeinbytes/1024;    
      long filesizeinmb=filesizeinkb/1024;    
  }
  </code></pre>