How to convert java.io.File to java.lang.Class
<p>I have the following code that retrieves a list of files from a folder and in my for statement i want to compare them to see do the names match</p>

<pre><code>        Class classFile = null;

        // Retrieve the java file 
        final File javaFolder = new File(filePath);

        // Retrieves all the class files
        List&lt;Class&gt; classFiles = new ArrayList&lt;&gt;();
        final File classFolder = new File(compileFile.getDirectoryForBin());
        classFiles = retrieveFiles.listClassFilesForFolder(classFolder);

        // compared the java files to the class files and add the correct files to the list
        for (Class currentClassFile : classFiles) {.....}
</code></pre>

<p>Im getting the following error</p>

<pre><code>java.lang.ClassCastException: java.io.File cannot be cast to java.lang.Class
at Java.OrganisingFiles.getClasses(OrganisingFiles.java:129)    
</code></pre>

<p>This is because i have a list of files that cannot be cast to Class in my for loop. Does anybody know how to convert a File to a Class type or is it better to just to cast all the files as objects as <code>java.lang.Class</code> is a subclass of <code>java.lang.Object</code>?</p>
