File 文件类处理 JAVA
程序员文章站
2022-03-25 23:05:46
...
在项目中使用SVN进行版本控制总是会让项目文件中存在.svn文件,对于项目文件的copy有很大的困扰,因此就写了一个简单的删除.svn文件的小程序
public class SvnClean {
/**
* 删除项目中的.svn目录(目录中有文件需要递归删除)
* @param dirName 项目路径
*/
public static void cleanSVNDir(String dirName){
try{
File file = new File(dirName);
if(file.isDirectory()){
File[] c_file = file.listFiles();
for(int i = 0;i < c_file.length;i++){
File s_file = c_file[i];
String fileName = s_file.getName();
if(s_file.isDirectory() && fileName.equals(".svn")){
cleanSVNFile(s_file.getPath());
s_file.delete();
}else{
cleanSVNDir(s_file.getPath());
}
}
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
* 删除SVN目录下的文件
* @param svnPath
*/
public static void cleanSVNFile(String svnPath){
try{
File file = new File(svnPath);
if(file.isDirectory()){
File[] c_file = file.listFiles();
for(int i = 0;i < c_file.length;i++){
File s_file = c_file[i];
if(s_file.isDirectory()){
/*删除目录下的文件*/
cleanSVNFile(s_file.getPath());
/*删除目录*/
s_file.delete();
}else{
s_file.delete();
}
}
}
}catch(Exception e){
throw new RuntimeException(e);
}
}
public static void main(String[] args){
cleanSVNDir("E:\\新建文件夹\\td-webapp");
}
}
文章来自:http://blog.csdn.net/huwenhu2007/article/details/19985907
public class SvnClean {
/**
* 删除项目中的.svn目录(目录中有文件需要递归删除)
* @param dirName 项目路径
*/
public static void cleanSVNDir(String dirName){
try{
File file = new File(dirName);
if(file.isDirectory()){
File[] c_file = file.listFiles();
for(int i = 0;i < c_file.length;i++){
File s_file = c_file[i];
String fileName = s_file.getName();
if(s_file.isDirectory() && fileName.equals(".svn")){
cleanSVNFile(s_file.getPath());
s_file.delete();
}else{
cleanSVNDir(s_file.getPath());
}
}
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
* 删除SVN目录下的文件
* @param svnPath
*/
public static void cleanSVNFile(String svnPath){
try{
File file = new File(svnPath);
if(file.isDirectory()){
File[] c_file = file.listFiles();
for(int i = 0;i < c_file.length;i++){
File s_file = c_file[i];
if(s_file.isDirectory()){
/*删除目录下的文件*/
cleanSVNFile(s_file.getPath());
/*删除目录*/
s_file.delete();
}else{
s_file.delete();
}
}
}
}catch(Exception e){
throw new RuntimeException(e);
}
}
public static void main(String[] args){
cleanSVNDir("E:\\新建文件夹\\td-webapp");
}
}
文章来自:http://blog.csdn.net/huwenhu2007/article/details/19985907
上一篇: 配置HSQLDB数据库[服务器模式]
下一篇: C++ --const修饰指针