Java solution Git@osc svn empty directory

Source: Internet
Author: User

[Email protected] SVN submission, the empty directory will appear as follows

Svn:E200015:Empty directories is not supported: {PATH}

Solution: Add files in an empty directory so that they meet the criteria

Written here in the Java language, other languages are handled in a similar way

Not much to say, directly on the code

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 (); Read-in File path

File root = new file (PATH);

Dealemptyfolder (root);
System.out.println ("End.");
}

Traverse Folder
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 ()); Empty folder Write
} catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
}
}

File Write
private static void Writetxt (String absolutepath) throws IOException {
TODO auto-generated Method Stub
String str = "This folder is Empty."; Write content
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 ();
}

}

Java Solution [email protected] SVN empty directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.