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
- String url = "http://svn.svnkit.com/repos/svnkit/trunk/doc ";
- String name = "anonymous ";
- String Password = "anonymous ";
- Svnrepository repository = NULL;
- Try {
- Repository = svnrepositoryfactory. Create (svnurl. parseuridecoded (URL ));
- Isvnauthenticationmanager authmanager = svnwcutil. createdefaauthauthenticationmanager (name, password );
- Repository. setauthenticationmanager (authmanager );
- } Catch (svnexception svne ){
- // Handle exception
- }
2. Get the Directory and file list of the specified path
Java code
- Public static void listentries (svnrepository repository, string path) throws svnexception {
- Collection entries = repository. getdir (path,-1, null, (Collection) null );
- Iterator = entries. iterator ();
- While (iterator. hasnext ()){
- Svndirentry entry = (svndirentry) iterator. Next ();
- System. Out. println ("/" + (path. Equals ("")? "": Path + "/") + entry. getname () +
- "(Author: '" + entry. getauthor () + "'; Revision:" + entry. getrevision () +
- "; Date:" + entry. getdate () + ")");
- If (entry. getkind () = svnnodekind. DIR ){
- Listentries (repository, (path. Equals (""))? Entry. getname (): path + "/" + entry. getname ());
- }
- }
- }