hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yannick PIERSON" <piers...@gmail.com>
Subject WebDAV access
Date Mon, 21 Apr 2008 13:25:27 GMT
Hi,
I want to develop thanks to HttpClient a WebDAV access to a remote IIS
server.
I want to retrieve and store data (files) on it.

------------------------------------------------------------------
I have ever started with this code :
DefaultHttpClient httpclient = new DefaultHttpClient();

httpclient.getCredentialsProvider().setCredentials(new
AuthScope("localhost", 80), new UsernamePasswordCredentials("admin",
"admin"));

HttpGet httpget = new HttpGet("
http://computer_name/webdav_access/Docs/ex.xls");

HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();

if (entity != null) {
    FileOutputStream destFile = new
FileOutputStream("c:\\temp\\conf_250206.pdf");

    byte buffer[]=new byte[4096];
    int nbLecture;
    InputStream in = entity.getContent();
    while( (nbLecture = in.read(buffer)) != -1 ) {
          destFile.write(buffer, 0, nbLecture);
    }
    destFile.close();
}

if (entity != null) {
    entity.consumeContent();
}

------------------------------------------------------------------

Are there more effective code to perform it ?

Thanks in advance,
Regards.

Yannick

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message