Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for
the NAME records.
775262
private function _writeExterns()
	{
		$countSheets = $this->_phpExcel->getSheetCount();
		// Create EXTERNCOUNT with number of worksheets
		$this->_writeExterncount($countSheets);

		// Create EXTERNSHEET for each worksheet
		for ($i = 0; $i < $countSheets; ++$i) {
			$this->_writeExternsheet($this->_phpExcel->getSheet($i)->getTitle());
		}
	}
862668
private function _writeExternsheetBiff8()
	{
		$total_references = count($this->_parser->_references);
		$record   = 0x0017;                     // Record identifier
		$length   = 2 + 6 * $total_references;  // Number of bytes to follow

		$supbook_index = 0;           // FIXME: only using internal SUPBOOK record
		$header           = pack("vv",  $record, $length);
		$data             = pack('v', $total_references);
		for ($i = 0; $i < $total_references; ++$i) {
			$data .= $this->_parser->_references[$i];
		}
		return $this->writeData($header . $data);
	}
1006740
private function _writeNames()
	{
		// total number of sheets
		$total_worksheets = $this->_phpExcel->getSheetCount();

		// Create the print area NAME records
		for ($i = 0; $i < $total_worksheets; ++$i) {
			$sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup();
			// Write a Name record if the print area has been defined
			if ($sheetSetup->isPrintAreaSet()) {
				// Print area
				$printArea = PHPExcel_Cell::splitRange($sheetSetup->getPrintArea());
				$printArea = $printArea[0];
				$printArea[0] = PHPExcel_Cell::coordinateFromString($printArea[0]);
				$printArea[1] = PHPExcel_Cell::coordinateFromString($printArea[1]);

				$print_rowmin = $printArea[0][1] - 1;
				$print_rowmax = $printArea[1][1] - 1;
				$print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1;
				$print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1;

				$this->_writeNameShort(
					$i, // sheet index
					0x06, // NAME type
					$print_rowmin,
					$print_rowmax,
					$print_colmin,
					$print_colmax
					);
			}
		}

		// Create the print title NAME records
		for ($i = 0; $i < $total_worksheets; ++$i) {
			$sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup();

			// simultaneous repeatColumns repeatRows
			if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) {
				$repeat = $sheetSetup->getColumnsToRepeatAtLeft();
				$colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
				$colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;

				$repeat = $sheetSetup->getRowsToRepeatAtTop();
				$rowmin = $repeat[0] - 1;
				$rowmax = $repeat[1] - 1;

				$this->_writeNameLong(
					$i, // sheet index
					0x07, // NAME type
					$rowmin,
					$rowmax,
					$colmin,
					$colmax
					);

			// (exclusive) either repeatColumns or repeatRows
			} else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {

				// Columns to repeat
				if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
					$repeat = $sheetSetup->getColumnsToRepeatAtLeft();
					$colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
					$colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;
				} else {
					$colmin = 0;
					$colmax = 255;
				}

				// Rows to repeat
				if ($sheetSetup->isRowsToRepeatAtTopSet()) {
					$repeat = $sheetSetup->getRowsToRepeatAtTop();
					$rowmin = $repeat[0] - 1;
					$rowmax = $repeat[1] - 1;
				} else {
					$rowmin = 0;
					$rowmax = 65535;
				}

				$this->_writeNameShort(
					$i, // sheet index
					0x07, // NAME type
					$rowmin,
					$rowmax,
					$colmin,
					$colmax
					);
			}
		}
	}
432955
private void writeCalendars(List<ProjectCalendar> records)
   {

      //
      // Write project calendars
      //
      for (ProjectCalendar record : records)
      {
         m_buffer.setLength(0);
         m_buffer.append("CLDR ");
         m_buffer.append(SDEFmethods.lset(record.getUniqueID().toString(), 2)); // 2 character used, USACE allows 1
         String workDays = SDEFmethods.workDays(record); // custom line, like NYYYYYN for a week
         m_buffer.append(SDEFmethods.lset(workDays, 8));
         m_buffer.append(SDEFmethods.lset(record.getName(), 30));
         m_writer.println(m_buffer);
      }
   }
927511
@Override
	public void writeRecord(Record record) throws IOException {
		int numRecFields = record.getNumFields();
		int readPos;

		for (int i = 0; i < this.numFields; i++) {
			readPos = this.recordPositions[i];
			if (readPos < numRecFields) {
				Value v = record.getField(this.recordPositions[i], this.classes[i]);
				if (v != null) {
					if (i != 0) {
						this.wrt.write(this.fieldDelimiter);
					}
					this.wrt.write(v.toString());
				} else {
					if (this.lenient) {
						if (i != 0) {
							this.wrt.write(this.fieldDelimiter);
						}
					} else {
						throw new RuntimeException("Cannot serialize record with <null> value at position: " + readPos);
					}
				}

			} else {
				if (this.lenient) {
					if (i != 0) {
						this.wrt.write(this.fieldDelimiter);
					}
				} else {
					throw new RuntimeException("Cannot serialize record with out field at position: " + readPos);
				}
			}

		}

		// add the record delimiter
		this.wrt.write(this.recordDelimiter);
	}
588939
@Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    // TODO: do we need to write/read the capacity?
    out.writeInt(entries.length);
    for(Entry entry : entries) {
      if(entry == null) {
        break;
      }
      entry.writeExternal(out);
    }
  }
1063457
def write_record(self, record, now):
        """"""
        self.write_name(record.name)
        self.write_short(record.type)
        if record.unique and self.multicast:
            self.write_short(record.clazz | _CLASS_UNIQUE)
        else:
            self.write_short(record.clazz)
        if now == 0:
            self.write_int(record.ttl)
        else:
            self.write_int(record.get_remaining_ttl(now))
        index = len(self.data)
        # Adjust size for the short we will write before this record
        #
        self.size += 2
        record.write(self)
        self.size -= 2

        length = len(b''.join(self.data[index:]))
        self.insert_short(index, length)
1341945
def _write_mef(self, key, extlist, outfile):
        """"""
        channel = self.fv.get_channel(self.chname)
        with fits.open(outfile, mode='update') as pf:
            # Process each modified data extension
            for idx in extlist:
                k = '{0}[{1}]'.format(key, self._format_extname(idx))
                image = channel.datasrc[k]

                # Insert data and header into output HDU
                pf[idx].data = image.get_data()
                self._write_header(image, pf[idx])

            # Write history to PRIMARY
            self._write_history(key, pf['PRIMARY'])
307447
private function _saveRecords()
    {
        $offset = 50;
        if (is_array($this->records) && (count($this->records) > 0)) {
            foreach ($this->records as $index => $record) {
                //Save the record to the .shp file
                $record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1);

                //Save the record to the .shx file
                fwrite($this->SHXFile, pack('N', $offset));
                fwrite($this->SHXFile, pack('N', $record->getContentLength()));
                $offset += (4 + $record->getContentLength());
            }
        }
    }
1370950
function _storeNames()
    {
        // Create the print area NAME records
        $total_worksheets = count($this->_worksheets);
        for ($i = 0; $i < $total_worksheets; $i++) {
            // Write a Name record if the print area has been defined
            if (isset($this->_worksheets[$i]->print_rowmin)) {
                $this->_storeNameShort(
                    $this->_worksheets[$i]->index,
                    0x06, // NAME type
                    $this->_worksheets[$i]->print_rowmin,
                    $this->_worksheets[$i]->print_rowmax,
                    $this->_worksheets[$i]->print_colmin,
                    $this->_worksheets[$i]->print_colmax
                    );
            }
        }

        // Create the print title NAME records
        $total_worksheets = count($this->_worksheets);
        for ($i = 0; $i < $total_worksheets; $i++) {
            $rowmin = $this->_worksheets[$i]->title_rowmin;
            $rowmax = $this->_worksheets[$i]->title_rowmax;
            $colmin = $this->_worksheets[$i]->title_colmin;
            $colmax = $this->_worksheets[$i]->title_colmax;

            // Determine if row + col, row, col or nothing has been defined
            // and write the appropriate record
            //
            if (isset($rowmin) && isset($colmin)) {
                // Row and column titles have been defined.
                // Row title has been defined.
                $this->_storeNameLong(
                    $this->_worksheets[$i]->index,
                    0x07, // NAME type
                    $rowmin,
                    $rowmax,
                    $colmin,
                    $colmax
                    );
            } elseif (isset($rowmin)) {
                // Row title has been defined.
                $this->_storeNameShort(
                    $this->_worksheets[$i]->index,
                    0x07, // NAME type
                    $rowmin,
                    $rowmax,
                    0x00,
                    0xff
                    );
            } elseif (isset($colmin)) {
                // Column title has been defined.
                $this->_storeNameShort(
                    $this->_worksheets[$i]->index,
                    0x07, // NAME type
                    0x0000,
                    0x3fff,
                    $colmin,
                    $colmax
                    );
            } else {
                // Print title hasn't been defined.
            }
        }
    }
725617
private void setIndex() {
		int DataCounter, PBASCounter, PLOCCounter, PCONCounter, NumRecords, indexBase;
		byte[] RecNameArray = new byte[4];
		String RecName;

		DataCounter = 0;
		PBASCounter = 0;
		PLOCCounter = 0;
		PCONCounter = 0;

		indexBase = getIntAt(absIndexBase + macJunk);
		NumRecords = getIntAt(absIndexBase - 8 + macJunk);

		for (int record = 0; record <= NumRecords - 1; record++) {
			getSubArray(RecNameArray, (indexBase + (record * 28)));
			RecName = new String(RecNameArray);
			if (RecName.equals("FWO_"))
				FWO = indexBase + (record * 28) + 20;
			if (RecName.equals("DATA")) {
				++DataCounter;
				if (DataCounter == 9)
					DATA9 = indexBase + (record * 28) + 20;
				if (DataCounter == 10)
					DATA10 = indexBase + (record * 28) + 20;
				if (DataCounter == 11)
					DATA11 = indexBase + (record * 28) + 20;
				if (DataCounter == 12)
					DATA12 = indexBase + (record * 28) + 20;
			}
			if (RecName.equals("PBAS")) {
				++PBASCounter;
				if (PBASCounter == 2)
					PBAS2 = indexBase + (record * 28) + 20;
			}
			if (RecName.equals("PLOC")) {
				++PLOCCounter;
				if (PLOCCounter == 2)
					PLOC = indexBase + (record * 28) + 20;
			}
			if (RecName.equals("PCON")) {
				++PCONCounter;
				if (PCONCounter == 2)
					PCON = indexBase + (record * 28) + 20;
			}

		} //next record
		traceLength = getIntAt(DATA12 - 8);
		seqLength = getIntAt(PBAS2 - 4);
		PLOC = getIntAt(PLOC) + macJunk;
		DATA9 = getIntAt(DATA9) + macJunk;
		DATA10 = getIntAt(DATA10) + macJunk;
		DATA11 = getIntAt(DATA11) + macJunk;
		DATA12 = getIntAt(DATA12) + macJunk;
		PBAS2 = getIntAt(PBAS2) + macJunk;
		PCON = getIntAt(PCON) + macJunk;
	}
173710
protected void tally(WARCRecordType warcRecordType, long contentBytes, long totalBytes, long sizeOnDisk) {
        if (tmpStats == null) {
            tmpStats = new HashMap<String, Map<String,Long>>();
        }

        // add to stats for this record type
        Map<String, Long> substats = tmpStats.get(warcRecordType.toString());
        if (substats == null) {
            substats = new HashMap<String, Long>();
            tmpStats.put(warcRecordType.toString(), substats);
        }
        subtally(substats, contentBytes, totalBytes, sizeOnDisk);
        
        // add to totals
        substats = tmpStats.get(TOTALS);
        if (substats == null) {
            substats = new HashMap<String, Long>();
            tmpStats.put(TOTALS, substats);
        }
        subtally(substats, contentBytes, totalBytes, sizeOnDisk);
    }
1023447
def write(self):
        
        index_file = self.path
        new_index_file = index_file + '.new'
        bak_index_file = index_file + '.bak'

        if not self._db:
            return

        with open(new_index_file, 'w') as f:
            json.dump(self._db, f, indent=4)

        if exists(index_file):
            copy(index_file, bak_index_file)

        rename(new_index_file, index_file)
49074
public void writeExternal(ObjectOutput out) throws IOException {

		out.writeLong(calleeCSeq);
		out.writeLong(callerCSeq);
		out.writeUTF(calleeContact.toString());
		out.writeUTF(callerContact.toString());

		out.writeInt(calleeRouteSet.size());
		Iterator<javax.sip.address.Address> i = calleeRouteSet.iterator();
    	while (i.hasNext()) {
    		javax.sip.address.Address a = i.next();
    		out.writeUTF(a.toString());
    	}

    	out.writeInt(callerRouteSet.size());
		i = callerRouteSet.iterator();
    	while (i.hasNext()) {
    		javax.sip.address.Address a = i.next();
    		out.writeUTF(a.toString());
    	}

    	out.writeUTF(toHeader.getAddress().toString());
    	out.writeUTF(toHeader.getTag());
    	out.writeUTF(fromHeader.getAddress().toString());
		out.writeUTF(fromHeader.getTag());
		out.writeUTF(callId);
	}
660510
def write_record(self, warc_record):
        
        warc_record.write_to(self.fileobj)
        # Each warc record is written as separate member in the gzip file
        # so that each record can be read independetly.
        if isinstance(self.fileobj, gzip2.GzipFile):
            self.fileobj.close_member()
1228318
private function _readExternSheet()
	{
		$length = self::_GetInt2d($this->_data, $this->_pos + 2);
		$recordData = substr($this->_data, $this->_pos + 4, $length);

		// move stream pointer to next record
		$this->_pos += 4 + $length;

		// external sheet references provided for named cells
		if ($this->_version == self::XLS_BIFF8) {
			// offset: 0; size: 2; number of following ref structures
			$nm = self::_GetInt2d($recordData, 0);
			for ($i = 0; $i < $nm; ++$i) {
				$this->_ref[] = array(
					// offset: 2 + 6 * $i; index to EXTERNALBOOK record
					'externalBookIndex' => self::_GetInt2d($recordData, 2 + 6 * $i),
					// offset: 4 + 6 * $i; index to first sheet in EXTERNALBOOK record
					'firstSheetIndex' => self::_GetInt2d($recordData, 4 + 6 * $i),
					// offset: 6 + 6 * $i; index to last sheet in EXTERNALBOOK record
					'lastSheetIndex' => self::_GetInt2d($recordData, 6 + 6 * $i),
				);
			}
		}
	}
1105338
def __shxRecord(self, offset, length):
         """"""
         f = self.__getFileObj(self.shx)
         f.write(pack(">i", offset // 2))
         f.write(pack(">i", length))