虽然eclipse中有删除svn中不需要功能,但是我还是自己手工写了一个
public class DeleteFile {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
DeleteFile.deleteSVN("E:/com");
}
/**
* 删除svn中不必要的文件
*/
public static void deleteSVN(String filePath) throws Exception{
File file = new File(filePath);
if(!file.isDirectory()){
file.delete();
}else {
String[] filelist = file.list();
for(int i=0; i< filelist.length; i++) {
String temp = filePath + "/" + filelist[i];
File subfile = new File(temp);
if(filelist[i].equals(".svn") && subfile.isDirectory()){
System.out.println("delete directory:" + temp);
delete(temp);
} else if(subfile.isDirectory() && !filelist[i].equals(".svn")){
deleteSVN(temp);
}
}
}
}
/**
* 删除目录及目录下的所有文件
* @param filePath
* @throws Exception
*/
public static void delete(String filePath) throws Exception{
File file = new File(filePath);
if(!file.isDirectory()) {
file.delete();
} else {
String[] filelist = file.list();
for(int i = 0; i< filelist.length; i++) {
File subfile = new File(filePath + "/" + filelist[i]);
if(!subfile.isDirectory()) {
subfile.delete();
} else {
delete(filePath + "/" + filelist[i]);
}
}
file.delete();
}
}
}