import java.io.File;
public class DeleteSvn {
/**
* @param args
*/
public static void main(String[] args) {
String a = args[0];
if (a == null || a.trim().length() == 0) {
System.out.println("input error args.");
return;
}
File file = new File(a);
if (file.isFile()) {
System.out.println(a + "is a file.");
return;
}
process(file);
}
private static void process(File file) {
File[] fs = file.listFiles();
if (fs != null) {
for (File f : fs) {
if (f.isDirectory()) {
if (".svn".equalsIgnoreCase(f.getName())) {
deleteFile(f);
f.delete();
} else {
process(f);
}
}
}
}
}
private static void deleteFile(File file) {
File[] fs = file.listFiles();
if (fs != null) {
for (File f : fs) {
if (f.isDirectory()) {
deleteFile(f);
f.delete();
} else {
if (f.delete()) {
System.out.println(f.getAbsolutePath() + "is delete sucessful.");
} else {
System.out.println(f.getAbsolutePath() + "is delete unsucessful.");
}
}
}
}
}
}
public class DeleteSvn {
/**
* @param args
*/
public static void main(String[] args) {
String a = args[0];
if (a == null || a.trim().length() == 0) {
System.out.println("input error args.");
return;
}
File file = new File(a);
if (file.isFile()) {
System.out.println(a + "is a file.");
return;
}
process(file);
}
private static void process(File file) {
File[] fs = file.listFiles();
if (fs != null) {
for (File f : fs) {
if (f.isDirectory()) {
if (".svn".equalsIgnoreCase(f.getName())) {
deleteFile(f);
f.delete();
} else {
process(f);
}
}
}
}
}
private static void deleteFile(File file) {
File[] fs = file.listFiles();
if (fs != null) {
for (File f : fs) {
if (f.isDirectory()) {
deleteFile(f);
f.delete();
} else {
if (f.delete()) {
System.out.println(f.getAbsolutePath() + "is delete sucessful.");
} else {
System.out.println(f.getAbsolutePath() + "is delete unsucessful.");
}
}
}
}
}
}
本文介绍了一个简单的Java程序,该程序用于递归地搜索指定目录并删除所有的.svn文件夹。这对于清理版本控制系统遗留的文件特别有用。

被折叠的 条评论
为什么被折叠?



