FileDocCategorySizeDatePackage
ListExample.javaAPI DocExample2477Wed May 18 09:39:02 BST 2005com.discursive.jccook.slide

ListExample

public class ListExample extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		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" );
		}