File dir=null;
 dir=new File("c:/aaa.txt"); //or c:/aaa
 if( dir.isDirectory() )
   .......

解决方案 »

  1.   

    isDirectory()
        Tests whether the file denoted by this abstract pathname is a directory.
    isFile()
         Tests whether the file denoted by this abstract pathname is a normal file.
      

  2.   

    File file = new File("c://rea.txt"); 
    if( file.isDirectory() )
    {
       ..Directory
    }
    if (file.isFile())
    {
      ..File()
        
    }