svnで不要なファイルを削除

1721 ワード

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();
		}
	}
}