Java - get files names from directory
<p>I have an issue with a Java code where the directory names are being pulled along with the file names. I want to modify the following code to pull only files and not sub-directories from the given directory. I'm a Java newbie so it would be greatly appreciated if someone could answer with the modified code. I have tried a lot of things from past stack overflow answers and just couldn't get it to compile. </p>

<pre><code>CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "DirectoryList" as import java.io.*;
import java.sql.*;

public class DirectoryList
{
    public static void getList(String directory) throws SQLException
    {
       File path = new File(directory);
       String[] list = path.list();
       String element;

       for(int i = 0; i &lt; list.length; i++)
       {
          element = list[i];
          #sql {
                call Load_File_List_p(:element, :directory)
           };
       }
    }
}
/
</code></pre>

<p>Here is what I already tried:</p>

<pre><code>CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "DirectoryList" as import java.io.*;
import java.sql.*;

public class DirectoryList
{
    public static void getList(File directory) throws SQLException
    {
       File path = new File(directory);
       File[] listOfFiles = path.listFiles();

       for (File file : listOfFiles)
       {
          if (file.isFile())
          {   
             for(int i = 0; i &lt; listOfFiles.length; i++)
             {
                file = listOfFiles[i];
                #sql {
                      call Load_File_List_p(:file, :directory)
                     };
             }
          }
       }
    }
}
/
</code></pre>

<p>Thanks!</p>