String path="D:/a/b"; //随便给的一个目录 File file=new File(path); //new的一个File对象 if(file.isDirectory()){ //如果path表示的是一个目录则返回true // .... }