HttpClient client = new HttpClient();
String url = "http://www.discursive.com/jccook/dav/test.html";
Credentials credentials =
new UsernamePasswordCredentials("davuser", "davpass");
// List resources in top directory
WebdavResource resource = new WebdavResource(url, credentials);
System.out.println( "The three ways to Read resources.");
// Read to a temporary file
File tempFile = new File( resource.getName() );
resource.getMethod( tempFile );
System.out.println( "1. " + resource.getName() + " saved in file: " + tempFile.toString() );
// Read as a String
String resourceData = resource.getMethodDataAsString();
System.out.println( "2. Contents of " + resource.getName() + " as String." );
System.out.println( resourceData );
// Read with a stream
InputStream resourceStream = resource.getMethodData();
Reader reader = new InputStreamReader( resourceStream );
StringWriter writer = new StringWriter();
while( reader.ready() ) { writer.write( reader.read() ); }
System.out.println( "3. Contents of " + resource.getName() + " from InputStream.");
System.out.println( writer.toString() );
resource.close();