删除svn标识文件

package cn.yicha.sns.common.util;

import java.io.File;
import java.io.IOException;

public class DeleteSvnUtil {

public static void main(String[] args) {

File f = new File("E:\\workspace_yicha\\ws_2010\\gameCenter\\");

try {
showAllFiles(f);
} catch (Exception e) {
e.printStackTrace();
}
}

final static void showAllFiles(File dir) throws Exception {
File[] fs = dir.listFiles();
for (int i = 0; i < fs.length; i++) {
if (fs<i>.isDirectory()) {
try {

if (fs<i>.getName().equals(
".svn")) {
System.out.println(fs<i>.getAbsolutePath());
System.out.println(
"fileName:" + fs<i>.getName());
deleteDirectory(fs<i>);
} else {
System.out.println(
"not include .svn");
}
showAllFiles(fs<i>);
} catch (Exception e) {
}
}
}
}

static public void deleteDirectory(File dir) throws IOException {
if ((dir == null) || !dir.isDirectory()) {
throw new IllegalArgumentException(
"Argument " + dir+ " is not a directory. ");
}
File[] entries = dir.listFiles();
int sz = entries.length;
for (int i = 0; i < sz; i++) {
if (entries<i>.isDirectory()) {
deleteDirectory(entries<i>);
} else {
entries<i>.delete();
}
}
dir.delete();
}

}

lunzi   2010-11-15 16:56:05 评论:1   阅读:657   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog