String url = "http://www.discursive.com/jccook/dav/";
Credentials credentials =
new UsernamePasswordCredentials("davuser", "davpass");
// List resources in top directory
WebdavResource resource = new WebdavResource(url, credentials);
WebdavResource[] resources = resource.listWebdavResources();
System.out.println( "type name size type modified");
System.out.println( "--------------------------------------------------------------------");
for( int i = 0; i < resources.length; i++ ) {
WebdavResource item = resources[i];
String type;
if( item.isCollection() ) {
type = "dir";
} else {
type = "file";
}
System.out.print( StringUtils.rightPad( type, 6 ) );
System.out.print( StringUtils.rightPad( item.getName(), 15 ) );
System.out.print( StringUtils.rightPad( item.getGetContentLength() + "", 8 ) );
System.out.print( StringUtils.rightPad( item.getGetContentType(), 23 ) );
Date lastMod = new Date( item.getGetLastModified() );
System.out.print( StringUtils.rightPad( FastDateFormat.getInstance().format( lastMod ), 25 ));
System.out.print( "\n" );
}