public class file {
public static void main(String[] args){
if (args.length !=1){
fail("err!!");
System.exit(0);}
 try {delete(args[0]);}
 catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}
}

  public static void delete(String filename){
   File f=new File(filename);
   if (!f.exists()) fail("文件不存在!");
   if(!f.canWrite()) fail("文件已经写保护!");
   if (f.isDirectory()) {
   String[] dir=f.list();
   if (dir.length>0){
   fail("该目录非空!");
   }
   boolean suc =f.delete();
   if (!suc) fail("文件删除失败");
  
   }
   } protected static void fail(String msg) throws IllegalArgumentException{
throw new IllegalArgumentException(msg); 
  }
}
运行:javac file.java通过
 问题1: java file a.txt//删除当前目录下的a.txt文件,这样做对吗?
       结果: Exception in thread "main" java.lang.NoClassDefFoundError: file  ///为何???