java递归实现文件的删除和拷贝
来源:优易学  2010-1-15 12:24:30   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  }

  f.delete();

  }

  //拷贝整个文件夹的方法

  public void copyFiles(String path1, String path2) throws Exception {

  // TODO Auto-generated method stub

  File file = new File(path1);

  if(file.isDirectory())

  {

  File f = new File(path2);

  if(!f.exists()) f.mkdir();

  File[] files = file.listFiles();

  for (File file2 : files) {

  //System.out.println(file2.toString()+"-----"+path2+"/"+file2.getName());

  copyFiles(file2.toString(),path2+"/"+file2.getName());

  }

  }else

  {

  copy(path1,path2);

  }

  }

上一页  [1] [2] [3] 下一页

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训