日期:2014-05-20  浏览次数:20639 次

急求助判断文件夹是否存在
下面这段程序只执行到File   file=new   file( "f:\\programme ");就不向下执行了,并且提示cannot   find   symbol   class   file这是什么原因.
import   java.io.File;
class   file0801
{
public   static   void   main(String   args[])
{
        File   file=new   file( "f:\\programme ");
if(file.exists())
{
System.out.println   ( "文件夹已经存在 ");//如果存在就不用建立
}
else
{
file.mkdir();//没有存在就在建立一个
}
}


}

------解决方案--------------------
File file=new File( "f:\\programme ");
------解决方案--------------------
String filename=jtfPath.getText(); //从输入框得到文件名
File sfile=new File(filename); //实例化一个文件

if (!sfile.exists()){ //如果文件不存在
showMessage(filename+ " 文件不存在. "); //显示信息