protected long writeHeader(java.io.RandomAccessFile logFile)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "writeHeader",
                        new Object[] { logFile, new Integer(instanceVersion), new Byte(sectorByte),
                                      new Long(startByteAddress), new Long(fileSize) }
                            );

        ObjectManagerByteArrayOutputStream logHeaderStream = new ObjectManagerByteArrayOutputStream(headerLength);
        java.io.DataOutputStream logHeader = new java.io.DataOutputStream(logHeaderStream);

        // Create the data in the log headerBuffer.
        try {
            logHeader.writeByte(0); // Skip over sector byte, for saving sector bits.
            logHeader.writeInt(instanceVersion);
            logHeader.writeByte(sectorByte); // Byte [5].
            logHeader.writeChars(signature);
            logHeader.writeLong(startByteAddress);
            logHeader.writeLong(fileSize);
            logHeader.writeLong(++headerSequence);
            headerWriteTime = System.currentTimeMillis();
            logHeader.writeLong(headerWriteTime);

        } catch (java.io.IOException exception) {
            // No FFDC Code Needed.
            ObjectManager.ffdc.processException(this, cclass, "writeHeader", exception, "1:265:1.8");

            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this,
                           cclass,
                           "writeHeader",
                           exception);
            throw new PermanentIOException(this,
                                           exception);
        } // catch java.io.IOException.

        long filePosition = 0;
        byte[] headerBuffer = logHeaderStream.getBuffer();
        // Set the sector bits in the header to be consistent with the sector bits starting 
        // at the start byte address. This is not much use for validating the header has been
        // written completely because we may rewrite it several times without changing the
        // sector bits, however it does help check that the file is a valid log file.
        // Since we only have data in the first sector, in is only really necessary
        // for the first sector to be written successfully. 
        FileLogOutput.setSectorBits(headerBuffer, 0, sectorByte);

        try {
            logFile.seek(0); // Start writing at the head of the file.
            // Write two LogHeaders.
            for (int i = 0; i < 2; i++) {
                logFile.write(headerBuffer,
                              0,
                              headerLength);
                filePosition = filePosition + headerLength;
            } // for 2 log headers.

        } catch (java.io.IOException exception) {
            // No FFDC Code Needed.
            ObjectManager.ffdc.processException(this, cclass, "writeHeader", exception, "1:298:1.8");

            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this,
                           cclass,
                           "writeHeader",
                           exception);
            throw new PermanentIOException(this,
                                           exception);
        } // catch java.io.IOException.

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "writeHeader",
                       new Object[] { new Long(filePosition), new Long(headerSequence), new java.util.Date(headerWriteTime) });
        return filePosition;
    }
protected long writeHeader ( java . io . RandomAccessFile logFile ) throws ObjectManagerException { if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . entry ( this , cclass , "writeHeader" , new Object [ ] { logFile , new Integer ( instanceVersion ) , new Byte ( sectorByte ) , new Long ( startByteAddress ) , new Long ( fileSize ) } ) ; ObjectManagerByteArrayOutputStream logHeaderStream = new ObjectManagerByteArrayOutputStream ( headerLength ) ; java . io . DataOutputStream logHeader = new java . io . DataOutputStream ( logHeaderStream ) ; try { logHeader . writeByte ( 0 ) ; logHeader . writeInt ( instanceVersion ) ; logHeader . writeByte ( sectorByte ) ; logHeader . writeChars ( signature ) ; logHeader . writeLong ( startByteAddress ) ; logHeader . writeLong ( fileSize ) ; logHeader . writeLong ( ++ headerSequence ) ; headerWriteTime = System . currentTimeMillis ( ) ; logHeader . writeLong ( headerWriteTime ) ; } catch ( java . io . IOException exception ) { ObjectManager . ffdc . processException ( this , cclass , "writeHeader" , exception , "1:265:1.8" ) ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , "writeHeader" , exception ) ; throw new PermanentIOException ( this , exception ) ; } long filePosition = 0 ; byte [ ] headerBuffer = logHeaderStream . getBuffer ( ) ; FileLogOutput . setSectorBits ( headerBuffer , 0 , sectorByte ) ; try { logFile . seek ( 0 ) ; for ( int i = 0 ; i < 2 ; i ++ ) { logFile . write ( headerBuffer , 0 , headerLength ) ; filePosition = filePosition + headerLength ; } } catch ( java . io . IOException exception ) { ObjectManager . ffdc . processException ( this , cclass , "writeHeader" , exception , "1:298:1.8" ) ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , "writeHeader" , exception ) ; throw new PermanentIOException ( this , exception ) ; } if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , "writeHeader" , new Object [ ] { new Long ( filePosition ) , new Long ( headerSequence ) , new java . util . Date ( headerWriteTime ) } ) ; return filePosition ; }
<p>
Write the FileLogHeader to a FileChannel.

@param java.io.RandomAccessFile the log file.
@return long the position of the log file after the write.
@author IBM Corporation

@throws PermanentIOException
if the is an underlting java.io.IOException.