标签:
Git@OSC SVN方式提交,空目录将出现下述情况
svn: E200015: Empty directories is not supported: {PATH}
解决方案:空目录中添加文件使其满足条件即可
此处使用Java语言编写,其他语言处理方式类似
不多说,直接上代码
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class DealEmptyFolder {
public static void main(String[] args){
String PATH = "";
System.out.print("Please input folder path :");
Scanner scan = new Scanner(System.in);
PATH = scan.nextLine(); //读入文件路径
File root = new File(PATH);
DealEmptyFolder(root);
System.out.println("End.");
}
//遍历文件夹
private static void DealEmptyFolder(File root) {
// TODO Auto-generated method stub
File[] fs = root.listFiles();
for(int i = 0; i < fs.length; i++){
System.out.println(fs[i].getAbsolutePath());
if(fs[i].isDirectory() && fs[i].listFiles().length > 0){
DealEmptyFolder(fs[i]);
}else if(fs[i].isDirectory() && fs[i].listFiles().length == 0){
try {
WriteTxt(fs[i].getAbsolutePath()); //空文件夹写入
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
//文件写入
private static void WriteTxt(String absolutePath) throws IOException {
// TODO Auto-generated method stub
String str = "This folder is Empty."; //写入内容
File newFile = new File(absolutePath + "/readme.txt");
if(!newFile.exists()){
newFile.createNewFile();
}
FileWriter fw = new FileWriter(newFile.getName(), true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(str);
bw.close();
}
}
标签:
原文地址:http://my.oschina.net/u/1468096/blog/505224