2011-04-07 76 views
1

我在我的android設備上使用雅加達/幻燈片項目來實現webDAV客戶端。 我得到了所有必要的jar文件到外部庫, 我的代碼:在Android上實現WebDAV客戶端

package com.android.webdav; 

import java.io.File; 
import java.io.IOException; 
import java.net.MalformedURLException; 

import org.apache.commons.httpclient.HttpException; 
import org.apache.util.HttpURL; 
import org.apache.webdav.lib.WebdavResource; 

import android.app.Activity; 
import android.os.Bundle; 

public class Webdav extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     try { 
      HttpURL hrl = new HttpURL("serverUrl"); 
      hrl.setUserInfo("username", "password"); 
      WebdavResource wdr = new WebdavResource(hrl); 
      File fn = new File("remote-file"); 
      wdr.getMethod(fn); 
      File LocFile = new File("mnt/sdcard/test/"); 
      wdr.putMethod(LocFile); 
      wdr.close(); 
     } catch (MalformedURLException e) { 
      e.printStackTrace(); 
     } catch (HttpException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

    } 
} 

,但我得到的錯誤,

java.lang.NoClassDefFoundError: org.apache.webdav.lib.WebdavResource 

上面的類罐中已經添加。 需要幫助。

感謝

回答