code: void copyIndex(final AbstractIndex index) throws IOException
     {
        // commit changes to directory on other index.
        index.commit(true);
        // simply copy over the files
        byte[] buffer = new byte[1024];
        Directory dir = index.getDirectory();
        Directory dest = getDirectory();
        String[] files = dir.listAll();
        for (int i = 0; i < files.length; i++)
        {
           IndexInput in = dir.openInput(files[i]);
           try
           {
              IndexOutput out = dest.createOutput(files[i]);
              try
              {
                 long remaining = in.length();
                 while (remaining > 0)
                 {
                    int num = (int)Math.min(remaining, buffer.length);
                    in.readBytes(buffer, 0, num);
                    out.writeBytes(buffer, num);
                    remaining -= num;
                 }
              }
              finally
              {
                 out.close();
              }
           }
           finally
           {
              in.close();
           }
        }
     }
docs: Copies <code>index</code> into this persistent index. This method should
  only be called when <code>this</code> index is empty otherwise the
  behaviour is undefined.
  
  @param index the index to copy from.
  @throws IOException if an error occurs while copying.