Wednesday, December 31, 2008

Retrieving an Array's Class Using the Component Type

Recently I needed to implement a method that returns class of an array based on its component type. E.g. for String.class, the method should return String[].class.

I tried to google, but the results were quite disappointing: it appears that none of the java.lang.reflect.* classes provides such a functionality. So I did a workaround:

public static Class<?> getArrayClassByComponentType(Class<?> ctype) {
return Array.newInstance(ctype, 0).getClass();

As you can see, I create a temporary array of size zero and return its class. Since arrays always have a default constructor, it will always work.

I'm still interested to know, if there is more elegant solution...

Monday, December 1, 2008

Open WebDAV from Windows

WebDAV stands for "Web-based Distributed Authoring and Versioning". It is a set of extensions to the HTTP protocol that lets users collaboratively edit and manage files on a remote web server.

This post summarizes the ways to open WebDAV folders:

1. WebDAV plug-in for Total Commander:

2. It's possible to use Window's built-in support: My Network Places / Add Network Place

3. Another option to use IE: File -> Open and check the "Open as Web Folder" checkbox.