private static void updateGroupIcon(DirectoryEntry root, int iconId, IconFile iconFile) throws IOException {
    DirectoryEntry subDirGroupIcon = root.findSubDir(DirectoryEntry.RT_GROUP_ICON).findSubDir(iconId);
    RawResource groupIcon = subDirGroupIcon.getRawResource();

    GroupIconResource gir = new GroupIconResource();
    gir.getHeader().copyFrom(iconFile.getHeader());
    Bin.ArrayOfBins<IconDirectory> sourceIcons = iconFile.getIcons();
    for (int i = 0; i < sourceIcons.size(); i++) {
      IconDirectory icon = sourceIcons.get(i);
      GroupIconResourceDirectory bin = new GroupIconResourceDirectory();
      bin.copyFrom(icon);
      bin.getDwId().setValue(i + 1);
      gir.getIcons().addBin(bin);
    }

    long size = gir.sizeInBytes();
    ByteArrayOutputStream bytesStream = new ByteArrayOutputStream((int)size);
    DataOutputStream stream = new DataOutputStream(bytesStream);
    gir.write(stream);
    groupIcon.setBytes(bytesStream.toByteArray());
  }
private static void updateGroupIcon(DirectoryEntry root, int iconId, IconFile iconFile)