Cannot get the size of a file without adding its extension( using JFileDialog)
<p>This is what I have so far. When I type in the name of a file withouts its extension in JFileDialog i find the file but i cant get the size....with the extension I get the size...but I want to get it without its extension</p>

<pre><code>public class DirScanner {

    public static void main(String[] argv) throws IOException {

        FileDialog fd = new FileDialog(new Frame());
        fd.setVisible(true);//make the jfilechooer visible
        if (fd.getFile() != null) {

            File f = new File(fd.getDirectory(), fd.getFile());//svae directory path and name of file
            String p = null;
            File fi = new File(fd.getDirectory());//store directory

            String[] d = fi.list();//store all file in directory
            for (int i = 0; i &lt; d.length; i++) {
                if (d[i] != null) {

                    //checks if wat the user type in the Jfieldoalog matches wat is in teh directory
                    if (d[i].matches(fd.getFile()) || d[i].startsWith(fd.getFile())) {

                        //gets the extension of teh file
                        p = d[i];
                        int dot = p.lastIndexOf(".");
                        String word = p.substring(0, dot);
                        String w = p.toUpperCase().substring(dot + 1);


                        System.out.println("\nFile Found\n");//output that file is found

                        //Display name of file with and without extension
                        System.out.println("Name of File: " + d[i]+  "\n"+  "File Name Without Extension: " + word + "\n" + "File type: " + w);
                    }
                }
            }
            //output size of fiel
            System.out.printf("size: " + f.length());
        }
    }
}
</code></pre>
