package test;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
public class FileManagerDeleteSvn
{
/**
* main方法
*/
public static void main(String[] args){
new FileManagerDeleteSvn().removeSvnFilesExample();
}
/**
* 例子--==-- 删除指定文件夹下的所有svn相关文件
*/
public void removeSvnFilesExample(){
//目标文件流
BufferedWriter utput = null;
//要移除SVN文件位置
// String removeDir = "F:/temp/qhdm";
String removeDir = "C:/Users/Beck/Desktop/arcgis/project/40/apache-tomcat-6.0.35-windows-x86/tomcat_Port8080_Send2AW/webapps/portal";
//日志文件
String logPath = "F:/temp/removeFileLog_"+Tools.formatDate(new Date(), "yyyy-MM-dd_HH-mm-ss")+".txt";
try {
//创建日志文件
try {
this.createFileAndAutoCreateDirectory(logPath);
utput = new BufferedWriter(new FileWriter(new File(logPath)));
} catch (Exception e) {
e.printStackTrace();
}
//
utput.write("删除指定文件夹下的所有svn相关文件---===---开始时间:"+Tools.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"+"\r\n"));
//删除指定文件夹下的所有svn相关文件
new FileManagerDeleteSvn().removeSvnFiles(removeDir,utput);
//
utput.write("删除指定文件夹下的所有svn相关文件---===---结束时间:"+Tools.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"+"\r\n"));
utput.write("删除结束"+"\r\n");
} catch (Exception e) {
e.printStackTrace();
} finally {
try { utput.flush(); } catch (IOException e) { e.printStackTrace(); }
try { utput.close(); } catch (IOException e) { e.printStackTrace(); }
utput = null;
System.out.println("删除指定文件夹下的所有svn相关文件---===---结束");
System.out.println("日志文件:"+logPath);
}
}
/**
* 删除指定文件夹下的所有svn相关文件
* @param filePath
*/
public void removeSvnFiles(String filePath, BufferedWriter utput) {
try {
File file = new File(filePath);
//存在且为文件夹
if (file.exists() && file.isDirectory()) {
String[] files = file.list();
for( int i=0; files!=null && i<files.length; i++ ){
if(".svn".equals(files[i])){
utput.write("-----=== 开始 "+filePath+"/.svn 文件夹删除 ===-----"+"\r\n");
System.out.println("-----=== 开始 "+filePath+"/.svn 文件夹删除 ===-----");
this.removeDirectoryAndFile(filePath+"/.svn", utput);
System.out.println("-----=== 结束 "+filePath+"/.svn 文件夹删除 ===-----");
utput.write("-----=== 结束 "+filePath+"/.svn 文件夹删除 ===-----"+"\r\n");
} else {
//递归
this.removeSvnFiles(filePath+"/"+files[i], utput);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 删除指定文件或文件夹(如果是文件夹,删除其下的所有文件和文件夹,最后删除该文件夹)
* @param filePath
*/
public void removeDirectoryAndFile(String filePath, BufferedWriter utput) {
try {
File file = new File(filePath);
boolean isDel = false;
if( file.isFile() ){
isDel = file.delete();
utput.write("delete file "+isDel+" ===== "+filePath+"\r\n");
System.out.println("delete file "+isDel+" ===== "+filePath);
} else {
String[] files = file.list();
if( files!=null && files.length>0 ){
//递归
for(int i=0; i<files.length; i++){
this.removeDirectoryAndFile(filePath+"/"+files[i], utput);
}
isDel = file.delete();
utput.write("delete directory "+isDel+" ===== "+filePath+"\r\n");
System.out.println("delete directory "+isDel+" ===== "+filePath);
} else {
isDel = file.delete();
utput.write("delete directory "+isDel+" ===== "+filePath+"\r\n");
System.out.println("delete directory "+isDel+" ===== "+filePath);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 创建文件,存在则不创建,文件夹不存在则自动创建
* @param filePath
*/
public void createFileAndAutoCreateDirectory(String filePath){
try{
File file = new File(filePath);//要创建的文件
File parentDir = new File(file.getParent());//要创建的文件所在的文件夹
if(!parentDir.exists()){ parentDir.mkdirs(); }//文件夹不存在则创建
if (!file.exists()) { file.createNewFile(); }//文件不存在则创建
} catch (Exception e) {
e.printStackTrace();
}
}
}
package test;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Tools
{
/**
*
* @param date //new Date()
* @param format //yyyy-MM-dd hh:mm:ss
* @return
*/
public static String formatDate(Date date, String format){
String result = null;
try{
DateFormat dateFormat = new SimpleDateFormat(format);
result = dateFormat.format(date);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
分享到:
相关推荐
解压过双击注册表注册一下,而后可以通过右击来去除某文件夹的svn文件
批量删除svn文件夹及文件,解除去除svn控制工具体批量删除svn文件夹及文件,解除去除svn控制工具体
TortoiseSVN 断开本地SVN关联功能的脚本文件 只需双击执行加入注册表即可。
简要cvs与svn的比较 ... 删除分remove和erase两种前者把本地和库中文件都删除 后者只是删除本地文件 不能删除文件夹 svn:支持文件重命名提交系统会提示删除旧文件,创建新文件 删除本地文件提交 库中文件也被删除
SVNService -remove to remove the service SVNService -debug to run as a console app for debugging Example: 比如,你的所有项目都在c:\svnrepo下,你可以如下 安装时用 SVNService -install -d -r c:\svn...
一、 下载安装SVN #检查是否安装了低版本的SVN [root@localhost /]# rpm -qa subversion ...[root@localhost modules]# yum remove subversion 安装SVN [root@localhost modules]# yum install subversion
win10下SVN客户端执行Cleanup也不能成功,不想通过删除整个库来解决该问题,因此个人编写脚本解决该问题。
//如果删除svn或者cvs文件夹则将第二个参数改为SVN或者CVS,第一个参数是项目路径 //如果项目叫 EXTDemo放在D盘 workspaces文件夹下, //new RemoveFolder("D:\\workspace\\EXTDemo","CVS"); new Remove...
2卸载旧版本SVN:yum remove subversion 3 yum安装svn: yum install subversion Complete,表示安装完成。 # 检测是否安装成功 svnserve –version 如下所示,表示已经安装成功! # 创建svn仓库 svnadmin create /...
yum remove subversion 2、安装 yum install subversion 3、建立SVN库 mkdir -p /home/svn/repos svnadmin create /home/svn/repos 执行上面的命令后,自动建立repositories库,查看/home/svn/repos 文件夹发现...
Svn 1.8.5安装(源码) 1,安装组件 yum install autoconf libtool expat-devel –y 1.1,安装apr wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.5.tar.gz -O apr.tar.gz tar -zxf apr.tar.gz cd apr...
工作需要和Takwai一起开发,于是找到Subversion和TortoiseSVN并用我的机器做服务器来实现版本控制,Subversion是个开源的版本控制服务端软件,而TortoiseSVN就是Subversion客户端之一,下面记录下我的安装过程。...
226540|(file-remove 21 .svn/tmp/svn-7B43C232) 226541|(sync-file-flags 目录名 文件名) 226542|(file-remove 21 .svn/tmp/svn-7B48224E) 4. 执行 sqlite3 .svn/wc.db "delete from work_queue". 把队列清空。 5. ...
226539|(sync-file-flags 93目录名 文件名) 226540|(file-remove 21 .svn/tmp/svn-7B43C232) 226541|(sync-file-flags 目录名 文件名) 226542|(file-remove 21 .svn/tmp/svn-7B48224E) 4. 执行 sqlite3 .svn/wc.db ...
226540|(file-remove 21 .svn/tmp/svn-7B43C232) 226541|(sync-file-flags 目录名 文件名) 226542|(file-remove 21 .svn/tmp/svn-7B48224E) 4. 执行 sqlite3 .svn/wc.db "delete from work_queue". 把队列清空。 5. ...
安装说明 系统环境:CentOS-6.3 安装方式:yum install ...[root@localhost modules]# yum remove subversion 安装SVN [root@localhost modules]# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_my
NOTE: Lazarus 0.9.31 Source from SVN 3-11-2011 Rev 33300 FreePascal 2.7.1 Source from SVN 17-09-2011 Rev 19464 ======> 01-10-2011 ver 2.20 ================================================= -ADD ...
SVN Service Wrapper for Windows This is my Win32 Service wrapper for SVN. Source is included, and its ... SVNService -remove to remove the service SVNService -debug to run as a console app for debugging
Cocoapods::RepoHg 添加 mercurial 支持以管理规范存储库简短的我们的团队一直在使用 Cocoapods 的内部分支,支持 svn、bzr 和 hg spec-repo。 由于 #1747 已关闭,我正在将该代码移植到插件中安装 $ gem install ...