ExportFileNameEncoder { public static String decodeZipPath( String encodedPath ) { String[] folders = encodedPath.split( "/" ); StringBuilder decodedPath = new StringBuilder( encodedPath.length() * 2 ); for ( int i = 0; i < folders.length; i++ ) { decodedPath.append( decodeZipFileName( folders[i] ) ); if ( i != folders.length - 1 || encodedPath.endsWith( "/" ) ) { decodedPath.append( "/" ); } } return decodedPath.toString(); }  static String encodeZipFileName( String fileName ); static String decodeZipFileName( String encodedFileName ); static String encodeZipPathName( String path ); static String decodeZipPath( String encodedPath );  }
@Test public void testDecodeZipPath() { assertEquals( "", ExportFileNameEncoder.decodeZipPath( "" ) ); assertEquals( "", ExportFileNameEncoder.decodeZipPath( "/" ) ); assertEquals( ".", ExportFileNameEncoder.decodeZipPath( "." ) ); assertEquals( "./..", ExportFileNameEncoder.decodeZipPath( "./.." ) ); assertEquals( "root.dir/mean dir/leaf dir_specials:(+)%^", ExportFileNameEncoder.decodeZipPath( "root.dir/mean+dir/leaf+dir_specials%3A%28%2B%29%25%5E" ) ); assertEquals( "/root.dir/mean dir/leaf dir_specials:(+)%^", ExportFileNameEncoder.decodeZipPath( "/root.dir/mean+dir/leaf+dir_specials%3A%28%2B%29%25%5E" ) ); assertEquals( "root.dir/mean dir/leaf dir_specials:(+)%^/", ExportFileNameEncoder.decodeZipPath( "root.dir/mean+dir/leaf+dir_specials%3A%28%2B%29%25%5E/" ) ); assertEquals( "/root.dir/mean dir/leaf dir_specials:(+)%^/", ExportFileNameEncoder.decodeZipPath( "/root.dir/mean+dir/leaf+dir_specials%3A%28%2B%29%25%5E/" ) ); }