0 Replies Latest reply: Nov 6, 2012 12:29 AM by Nithyarajan Manmathan-Oracle RSS

    Download files from WebDAV using Java program

    Nithyarajan Manmathan-Oracle

      We have requirement to download files from webDAV using java program. I heard using java API - sardine we can do this job. Can anyone pls share some sample code for doing this task.

      I am trying to connect to webDAV directory and list out the files using the below piece of code, but i am getting the following error though the url is correct : "com.googlecode.sardine.util.SardineException: Failed to get resources. Is the url valid?". Could anyone please correct me if i am doing anything wrong here.

      import com.googlecode.sardine.DavResource;
      import com.googlecode.sardine.Sardine;
      import com.googlecode.sardine.SardineFactory;
      import java.util.List;

      public class TestSardine {
      public static void main(String args[]){
      try {

      List<DavResource> resources;
      TestSardine ts = new TestSardine();
      resources = ts.listFiles();
      for (DavResource res : resources)

      }catch(Exception e){

      public List<DavResource> listFiles() throws Exception { 

      Sardine sardine = SardineFactory.begin("username", "pwd");
      List<DavResource> resources = sardine.getResources("url");

      return resources;


      Nithyarajan M