code: protected final void writeIndexLikeList( List<String> dirs, List<String> files, PrintWriter writer )
      {
          // JarIndex is sorting the directories by ascending order.
          // it has no value but cosmetic since it will be read into a
          // hashtable by the classloader, but we'll do so anyway.
          Collections.sort( dirs );
          Collections.sort( files );
          Iterator iter = dirs.iterator();
          while ( iter.hasNext() )
          {
              String dir = (String) iter.next();
  
              // try to be smart, not to be fooled by a weird directory name
              dir = dir.replace( '\\', '/' );
              if ( dir.startsWith( "./" ) )
              {
                  dir = dir.substring( 2 );
              }
              while ( dir.startsWith( "/" ) )
              {
                  dir = dir.substring( 1 );
              }
              int pos = dir.lastIndexOf( '/' );
              if ( pos != -1 )
              {
                  dir = dir.substring( 0, pos );
              }
  
              // name newline
              writer.println( dir );
          }
  
          iter = files.iterator();
          while ( iter.hasNext() )
          {
              writer.println( iter.next() );
          }
      }
docs: Writes the directory entries from the first and the filenames
  from the second list to the given writer, one entry per line.
  
  @param dirs   The directories
  @param files  The files
  @param writer The printwriter ;)