Program: 52523
Project: 52523
Buggy source:
/** 
 * Create both the bitstreams and the contents file. Any bitstreams that were originally registered will be marked in the contents file as such. However, the export directory will contain actual copies of the content files being exported.
 * @param c the DSpace context
 * @param i the item being exported
 * @param destDir the item's export directory
 * @throws Exception if there is any problem writing to the export directory
 */
private static void writeBitstreams(Context c,Item i,File destDir) throws Exception {
  File outFile=new File(destDir,"String_Node_Str");
  if (outFile.createNewFile()) {
    PrintWriter out=new PrintWriter(new FileWriter(outFile));
    Bundle[] bundles=i.getBundles();
    for (int j=0; j < bundles.length; j++) {
      Bitstream[] bitstreams=bundles[j].getBitstreams();
      String bundleName=bundles[j].getName();
      for (int k=0; k < bitstreams.length; k++) {
        Bitstream b=bitstreams[k];
        String myName=b.getName();
        String oldName=myName;
        int myPrefix=1;
        InputStream is=b.retrieve();
        boolean isDone=false;
        while (!isDone) {
          File fout=new File(destDir,myName);
          if (fout.createNewFile()) {
            FileOutputStream fos=new FileOutputStream(fout);
            Utils.bufferedCopy(is,fos);
            if (b.isRegisteredBitstream()) {
              out.println("String_Node_Str" + b.getStoreNumber() + "String_Node_Str"+ myName+ "String_Node_Str"+ bundleName);
            }
 else {
              out.println(myName + "String_Node_Str" + bundleName);
            }
            isDone=true;
          }
 else {
            myName=myPrefix + "String_Node_Str" + oldName;
            myPrefix++;
          }
        }
      }
    }
    out.close();
  }
 else {
    throw new Exception("String_Node_Str" + destDir);
  }
}

Fixed version (ground truth):
/** 
 * Create both the bitstreams and the contents file. Any bitstreams that were originally registered will be marked in the contents file as such. However, the export directory will contain actual copies of the content files being exported.
 * @param c the DSpace context
 * @param i the item being exported
 * @param destDir the item's export directory
 * @throws Exception if there is any problem writing to the export directory
 */
private static void writeBitstreams(Context c,Item i,File destDir) throws Exception {
  File outFile=new File(destDir,"String_Node_Str");
  if (outFile.createNewFile()) {
    PrintWriter out=new PrintWriter(new FileWriter(outFile));
    Bundle[] bundles=i.getBundles();
    for (int j=0; j < bundles.length; j++) {
      Bitstream[] bitstreams=bundles[j].getBitstreams();
      String bundleName=bundles[j].getName();
      for (int k=0; k < bitstreams.length; k++) {
        Bitstream b=bitstreams[k];
        String myName=b.getName();
        String oldName=myName;
        int myPrefix=1;
        InputStream is=b.retrieve();
        boolean isDone=false;
        while (!isDone) {
          File fout=new File(destDir,myName);
          if (fout.createNewFile()) {
            FileOutputStream fos=new FileOutputStream(fout);
            Utils.bufferedCopy(is,fos);
            is.close();
            fos.close();
            if (b.isRegisteredBitstream()) {
              out.println("String_Node_Str" + b.getStoreNumber() + "String_Node_Str"+ myName+ "String_Node_Str"+ bundleName);
            }
 else {
              out.println(myName + "String_Node_Str" + bundleName);
            }
            isDone=true;
          }
 else {
            myName=myPrefix + "String_Node_Str" + oldName;
            myPrefix++;
          }
        }
      }
    }
    out.close();
  }
 else {
    throw new Exception("String_Node_Str" + destDir);
  }
}