code: public long allocNew() throws IOException {
  
          int i;
          int entryIndex = -1;
  
          for (i = lastAllocatedCluster; i < lastClusterIndex; i++) {
              if (isFreeCluster(i)) {
                  entryIndex = i;
                  break;
              }
          }
          
          if (entryIndex < 0) {
              for (i = FIRST_CLUSTER; i < lastAllocatedCluster; i++) {
                  if (isFreeCluster(i)) {
                      entryIndex = i;
                      break;
                  }
              }
          }
          
          if (entryIndex < 0) {
              throw new IOException(
                      "FAT Full (" + (lastClusterIndex - FIRST_CLUSTER)
                      + ", " + i + ")"); //NOI18N
          }
          
          entries[entryIndex] = fatType.getEofMarker();
          lastAllocatedCluster = entryIndex % lastClusterIndex;
          if (lastAllocatedCluster < FIRST_CLUSTER)
              lastAllocatedCluster = FIRST_CLUSTER;
          
          return entryIndex;
      }
docs: Allocate a cluster for a new file
  
  @return long the number of the newly allocated cluster
  @throws IOException if there are no free clusters