Java - regular expression to split directory paths

I am trying to do the following in Java
give a directory path like "/a/b/c" I want to get a array of string as ["a", "b", "c"]. The code is as follows :

private static final String DIRECTORY_PATH_SEPARATOR = "/";  
    Iterator iter = testPaths.iterator();

            String[] directories;

        while( iter.hasNext() ) {

            directories = ( ( String ) iter.next() ).split(DIRECTORY_PATH_SEPARATOR);
        }

but what i get as array is space as well. I want to get all those strings with length>0.
how can I do that??

5
задан daydreamer 1 November 2010 в 06:08
поделиться