question: private static String [ ] norm ( String path ) { String [ ] elements = path . split ( "[/\\\\]" ) ; ArrayList < String > stack = new ArrayList < String > ( ) ; for ( String e : elements ) { if ( e . isEmpty ( ) || e . equals ( "." ) ) continue ; if ( e . equals ( ".." ) ) { if ( ! stack . isEmpty ( ) ) stack . remove ( stack . size ( ) - 1 ) ; else return null ; continue ; } stack . add ( e ) ; } return stack . toArray ( new String [ stack . size ( ) ] ) ; }
target:  process a path into an array of folders