Init Driver for Write mode
@param shpFile
@param shapeType
@param dbaseHeader
@throws IOException
506173
public void initDriver(File shpFile, ShapeType shapeType, DbaseFileHeader dbaseHeader) throws IOException {
        String path = shpFile.getAbsolutePath();
        String nameWithoutExt = path.substring(0,path.lastIndexOf('.'));
        this.shpFile = new File(nameWithoutExt+".shp");
        this.shxFile = new File(nameWithoutExt+".shx");
        this.dbfFile = new File(nameWithoutExt+".dbf");
        FileOutputStream shpFos = new FileOutputStream(shpFile);
        FileOutputStream shxFos = new FileOutputStream(shxFile);
        shapefileWriter = new ShapefileWriter(shpFos.getChannel(), shxFos.getChannel());
        this.shapeType = shapeType;
        shapefileWriter.writeHeaders(shapeType);
        dbfDriver.initDriver(dbfFile, dbaseHeader);
    }
1169623
def write
      begin
        buf = [ @flags, @length, @id, @crc].pack(FORMAT)
        crc = Zlib.crc32(buf, 0)
        @file.seek(@addr)
        @file.write(buf + [ crc ].pack('L'))
      rescue IOError => e
        PEROBS.log.fatal "Cannot write blob header into flat file DB: " +
          e.message
      end
    end
594150
def saveShp(self, target):
        """"""
        if not hasattr(target, "write"):
            target = os.path.splitext(target)[0] + '.shp'
        if not self.shapeType:
            self.shapeType = self._shapes[0].shapeType
        self.shp = self.__getFileObj(target)
        self.__shapefileHeader(self.shp, headerType='shp')
        self.__shpRecords()
1270436
public static void writeObjectToFile(String path, Object toWrite, SparkContext sc) throws IOException {
        writeObjectToFile(path, toWrite, sc.hadoopConfiguration());
    }
577163
def __shapefileHeader(self, fileObj, headerType='shp'):
        """"""
        f = self.__getFileObj(fileObj)
        f.seek(0)
        # File code, Unused bytes
        f.write(pack(">6i", 9994,0,0,0,0,0))
        # File length (Bytes / 2 = 16-bit words)
        if headerType == 'shp':
            f.write(pack(">i", self.__shpFileLength()))
        elif headerType == 'shx':
            f.write(pack('>i', ((100 + (len(self._shapes) * 8)) // 2)))
        # Version, Shape type
        f.write(pack("<2i", 1000, self.shapeType))
        # The shapefile's bounding box (lower left, upper right)
        if self.shapeType != 0:
            try:
                f.write(pack("<4d", *self.bbox()))
            except error:
                raise ShapefileException("Failed to write shapefile bounding box. Floats required.")
        else:
            f.write(pack("<4d", 0,0,0,0))
        # Elevation
        z = self.zbox()
        # Measure
        m = self.mbox()
        try:
            f.write(pack("<4d", z[0], z[1], m[0], m[1]))
        except error:
            raise ShapefileException("Failed to write shapefile elevation and measure values. Floats required.")
1284737
public static void writeBigInteger(BigInteger record, DataOutputView target) throws IOException {
		// null value support
		if (record == null) {
			target.writeInt(0);
			return;
		}
		// fast paths for 0, 1, 10
		// only reference equality is checked because equals would be too expensive
		else if (record == BigInteger.ZERO) {
			target.writeInt(1);
			return;
		}
		else if (record == BigInteger.ONE) {
			target.writeInt(2);
			return;
		}
		else if (record == BigInteger.TEN) {
			target.writeInt(3);
			return;
		}
		// default
		final byte[] bytes = record.toByteArray();
		// the length we write is offset by four, because null and short-paths for ZERO, ONE, and TEN
		target.writeInt(bytes.length + 4);
		target.write(bytes);
	}
1351058
function write(rows, geometry_type, geometries, callback) {

    var TYPE = types.geometries[geometry_type],
        writer = writers[TYPE],
        parts = writer.parts(geometries, TYPE),
        shpLength = 100 + (parts - geometries.length) * 4 + writer.shpLength(geometries),
        shxLength = 100 + writer.shxLength(geometries),
        shpBuffer = new ArrayBuffer(shpLength),
        shpView = new DataView(shpBuffer),
        shxBuffer = new ArrayBuffer(shxLength),
        shxView = new DataView(shxBuffer),
        extent = writer.extent(geometries);

    writeHeader(shpView, TYPE);
    writeHeader(shxView, TYPE);
    writeExtent(extent, shpView);
    writeExtent(extent, shxView);

    writer.write(geometries, extent,
        new DataView(shpBuffer, 100),
        new DataView(shxBuffer, 100),
        TYPE);

    shpView.setInt32(24, shpLength / 2);
    shxView.setInt32(24, (50 + geometries.length * 4));

    var dbfBuf = dbf.structure(rows);

    callback(null, {
        shp: shpView,
        shx: shxView,
        dbf: dbfBuf,
        prj: prj
    });
}
977792
public void writeHeader(OutputStreamCounter os) throws IOException {
		if (appendmode) {
			os.write(HEADER[0]);
		}
		else {
			os.write(HEADER[1]);
			os.write(getVersionAsByteArray(header_version));
			os.write(HEADER[2]);
			headerWasWritten = true;
		}
	}
930920
private void init(
            final Path output, final SAMFileHeader header, final boolean writeHeader,
            final TaskAttemptContext ctx)
            throws IOException
    {
        init(
                output.getFileSystem(ctx.getConfiguration()).create(output),
                header, writeHeader, ctx);
    }
90964
protected void writeDocumentHeader() throws IOException {
        writer.append("= ").append(this.configuration.getTitle()).append(NEW_LINE);

        if(isAttributesFileSet()) {
            writer.append("include::").append(this.configuration.getAsciiDocAttributesFile()).append("[]").append(NEW_LINE);
        }
        if (isAsciidoctorOutput()) {
            writer.append(":icons: font").append(NEW_LINE);
        }

        writer.append(NEW_LINE);
    }
1002666
public function writeImageHeader($width, $height, $colorType) 
    {
        $this->buffer->startChunk("IHDR");
        $this->buffer->writeUInt32BE($width);
        $this->buffer->writeUInt32BE($height);
        $this->buffer->writeUInt8(8); // Bit depth
        $this->buffer->writeUInt8($colorType);
        $this->buffer->writeUInt8(0); // Compression
        $this->buffer->writeUInt8(0); // Filter
        $this->buffer->writeUInt8(0); // Interlace
        $this->buffer->endChunk();
    }
81636
public void initializeFromFile(TreeIndexHeader header, PageFile<N> file) {
    this.dirCapacity = header.getDirCapacity();
    this.leafCapacity = header.getLeafCapacity();
    this.dirMinimum = header.getDirMinimum();
    this.leafMinimum = header.getLeafMinimum();

    if(getLogger().isDebugging()) {
      StringBuilder msg = new StringBuilder();
      msg.append(getClass());
      msg.append("\n file = ").append(file.getClass());
      getLogger().debugFine(msg.toString());
    }

    this.initialized = true;
  }
1281570
public static void writeFrameHeader(ByteBuf out, int payloadLength, byte type,
            Http2Flags flags, int streamId) {
        out.ensureWritable(FRAME_HEADER_LENGTH + payloadLength);
        writeFrameHeaderInternal(out, payloadLength, type, flags, streamId);
    }
856051
final void writeHeader()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "writeHeader");

        // Write the header.
        sharedBuffer.clear();
        sharedBuffer.putInt(version);
        for (int i = 0; i < signature.length(); i++)
            sharedBuffer.putChar(signature.charAt(i));
        sharedBuffer.putLong(objectStoreIdentifier);
        sharedBuffer.putLong(((Directory.Node) directory.root).byteAddress);
        sharedBuffer.putLong(((Directory.Node) directory.root).length);
        sharedBuffer.putInt(directory.getMinimumNodeSize());
        if (freeSpaceStoreArea == null) {
            sharedBuffer.putLong(0);
            sharedBuffer.putLong(0);
        } else {
            sharedBuffer.putLong(freeSpaceStoreArea.byteAddress);
            sharedBuffer.putLong(freeSpaceStoreArea.length);
        }
        sharedBuffer.putLong((long) freeSpaceByLength.size());
        sharedBuffer.putLong(sequenceNumber);
        sharedBuffer.putLong(storeFileSizeUsed);
        sharedBuffer.putLong(minimumStoreFileSize);
        sharedBuffer.putLong(maximumStoreFileSize);
        sharedBuffer.putInt(cachedManagedObjectsSize);

        sharedBuffer.flip();
        writeBuffer(sharedBuffer,
                    0);

        // Write the header twice.
        sharedBuffer.flip();
        writeBuffer(sharedBuffer,
                    pageSize);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "writeHeader"
                            );
    }
1259934
protected void write(BufferedWriter out, String type, byte[] data) throws IOException
    {
        writeHeader(out, type);
        out.write(this.base64.encode(data, 64));
        out.newLine();
        writeFooter(out, type);
    }
290431
public static void feedTableDataFromHeader(DbaseFileHeader header, CreateTableData data) throws IOException {
        for (int i = 0; i < header.getNumFields(); i++) {
            String fieldsName = header.getFieldName(i);
            final int type = dbfTypeToH2Type(header,i);
            Column column = new Column(fieldsName.toUpperCase(), type);
            column.setPrecision(header.getFieldLength(i)); // set string length
            data.columns.add(column);
        }
    }
1153412
protected function init(
        $shp_handle,
        $shp_size,
        $shx_handle,
        $shx_size,
        $dbf_handle,
        $dbf_size,
        $prj = null,
        $flags = 0
    ) {
        // Files
        $this->shp_handle = $shp_handle;
        $this->shx_handle = $shx_handle;
        $this->dbf_handle = $dbf_handle;
        $this->shp_size   = $shp_size;
        $this->shx_size   = $shx_size;
        $this->dbf_size   = $dbf_size;
        $this->prj        = $prj;
        
        // Flags
        $this->flags = array(
            self::FLAG_SUPPRESS_Z   => ($flags & self::FLAG_SUPPRESS_Z) > 0,
            self::FLAG_SUPPRESS_M   => ($flags & self::FLAG_SUPPRESS_M) > 0
        );
        
        // Misc
        $this->default_geometry_format  = self::GEOMETRY_ARRAY;
        $this->big_endian_machine       = current(unpack('v', pack('S', 0xff))) !== 0xff;
        $this->tot_records              = ($this->shx_size - 100) / 8;
        
        // Read Headers
        $this->readSHPHeader();
        $this->readDBFHeader();
        
        // Init record pointer
        $this->rewind();
    }