Java calls svnkit to obtain the svn Tree node

Source: Internet
Author: User

Svnkit (Javasvn)Is a pure Java SVN client library. Using svnkit does not require installation of any SVN client, and supports various operating systems.

This is a commercial software that is not commercially available for free.

Download svnkit.

 

Important steps:

1. Connect to the specified SVN Library

Java code
  1. String url = "http://svn.svnkit.com/repos/svnkit/trunk/doc ";
  2. String name = "anonymous ";
  3. String Password = "anonymous ";
  4. Svnrepository repository = NULL;
  5. Try {
  6. Repository = svnrepositoryfactory. Create (svnurl. parseuridecoded (URL ));
  7. Isvnauthenticationmanager authmanager = svnwcutil. createdefaauthauthenticationmanager (name, password );
  8. Repository. setauthenticationmanager (authmanager );
  9. } Catch (svnexception svne ){
  10. // Handle exception
  11. }

 

 

2. Get the Directory and file list of the specified path

Java code
  1. Public static void listentries (svnrepository repository, string path) throws svnexception {
  2. Collection entries = repository. getdir (path,-1, null, (Collection) null );
  3. Iterator = entries. iterator ();
  4. While (iterator. hasnext ()){
  5. Svndirentry entry = (svndirentry) iterator. Next ();
  6. System. Out. println ("/" + (path. Equals ("")? "": Path + "/") + entry. getname () +
  7. "(Author: '" + entry. getauthor () + "'; Revision:" + entry. getrevision () +
  8. "; Date:" + entry. getdate () + ")");
  9. If (entry. getkind () = svnnodekind. DIR ){
  10. Listentries (repository, (path. Equals (""))? Entry. getname (): path + "/" + entry. getname ());
  11. }
  12. }
  13. }

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.