Program: 78573
Project: 78573
Buggy source:
/** 
 * Compound File Format: <br> 1long(stream section position) + 1long(entry number in lookup map) + lookup map section + stream data section <br> The Lookup map is a hash map. The key is the relative path of the stram. The entry contains two long number. The first long is the start postion. The second long is the length of the stream. <br>
 * @param tempFolder
 * @param fileName
 * @return Whether the compound file was created successfully.
 */
private void createFileFromFolder() throws IOException {
  File targetFile=new File(fileName);
  ArchiveUtil.DeleteAllFiles(targetFile);
  RandomAccessFile compoundFile=null;
  compoundFile=new RandomAccessFile(targetFile,"String_Node_Str");
  compoundFile.writeLong(0);
  compoundFile.writeLong(0);
  ArrayList fileList=new ArrayList();
  getAllFiles(new File(tempFolder),fileList);
  long streamRelativePosition=0;
  long entryNum=0;
  for (int i=0; i < fileList.size(); i++) {
    File file=(File)fileList.get(i);
    String relativePath=ArchiveUtil.generateRelativePath(tempFolder,file.getAbsolutePath());
    compoundFile.writeUTF(relativePath);
    compoundFile.writeLong(streamRelativePosition);
    compoundFile.writeLong(file.length());
    streamRelativePosition+=file.length();
    entryNum++;
  }
  long streamSectionPos=compoundFile.getFilePointer();
  for (int i=0; i < fileList.size(); i++) {
    File file=(File)fileList.get(i);
    copyFileIntoTheArchive(file,compoundFile);
  }
  compoundFile.seek(0);
  compoundFile.writeLong(streamSectionPos);
  compoundFile.writeLong(entryNum);
  compoundFile.close();
}

Fixed version (ground truth):
/** 
 * Compound File Format: <br> 1long(stream section position) + 1long(entry number in lookup map) + lookup map section + stream data section <br> The Lookup map is a hash map. The key is the relative path of the stram. The entry contains two long number. The first long is the start postion. The second long is the length of the stream. <br>
 * @param tempFolder
 * @param fileName
 * @return Whether the compound file was created successfully.
 */
private void createFileFromFolder() throws IOException {
  File targetFile=new File(fileName);
  ArchiveUtil.DeleteAllFiles(targetFile);
  RandomAccessFile compoundFile=null;
  compoundFile=new RandomAccessFile(targetFile,"String_Node_Str");
  compoundFile.writeLong(0);
  compoundFile.writeLong(0);
  ArrayList fileList=new ArrayList();
  getAllFiles(new File(tempFolder),fileList);
  if (streamSorter != null) {
    ArrayList streamNameList=new ArrayList();
    for (int i=0; i < fileList.size(); i++) {
      File file=(File)fileList.get(i);
      streamNameList.add(ArchiveUtil.generateRelativePath(tempFolder,file.getAbsolutePath()));
    }
    ArrayList sortedNameList=streamSorter.sortStream(streamNameList);
    if (sortedNameList != null) {
      fileList.clear();
      for (int i=0; i < sortedNameList.size(); i++) {
        String fileName=ArchiveUtil.generateFullPath(tempFolder,(String)sortedNameList.get(i));
        fileList.add(new File(fileName));
      }
    }
  }
  long streamRelativePosition=0;
  long entryNum=0;
  for (int i=0; i < fileList.size(); i++) {
    File file=(File)fileList.get(i);
    String relativePath=ArchiveUtil.generateRelativePath(tempFolder,file.getAbsolutePath());
    compoundFile.writeUTF(relativePath);
    compoundFile.writeLong(streamRelativePosition);
    compoundFile.writeLong(file.length());
    streamRelativePosition+=file.length();
    entryNum++;
  }
  long streamSectionPos=compoundFile.getFilePointer();
  for (int i=0; i < fileList.size(); i++) {
    File file=(File)fileList.get(i);
    copyFileIntoTheArchive(file,compoundFile);
  }
  compoundFile.seek(0);
  compoundFile.writeLong(streamSectionPos);
  compoundFile.writeLong(entryNum);
  compoundFile.close();
}