Git@OSC SVN方式提交,空目錄將出現下述狀況 java
svn: E200015: Empty directories is not supported: {PATH} svn
解決方案:空目錄中添加文件使其知足條件便可 get
此處使用Java語言編寫,其餘語言處理方式相似 input
很少說,直接上代碼 it
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.");
} io
//遍歷文件夾
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();
}
}
}
} class
//文件寫入
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();
}
} import