private void writeHeader(WritableByteChannel channel) throws IOException
    {
        //write descriptive text
        MatFileHeader header = MatFileHeader.createHeader();
        char[] dest = new char[116];
        char[] src = header.getDescription().toCharArray();
        System.arraycopy(src, 0, dest, 0, src.length);

        byte[] endianIndicator = header.getEndianIndicator();

        ByteBuffer buf = ByteBuffer.allocateDirect(dest.length * 2 /* Char size */ + 2 + endianIndicator.length);

        for ( int i = 0; i < dest.length; i++ )
        {
            buf.put( (byte)dest[i] );
        }
        //write subsyst data offset
        buf.position( buf.position() + 8);

        //write version
        int version = header.getVersion();
        buf.put( (byte)(version >> 8) );
        buf.put( (byte)version );

        buf.put( endianIndicator );

        buf.flip();
        channel.write(buf);
    }
private void writeHeader ( WritableByteChannel channel ) throws IOException { MatFileHeader header = MatFileHeader . createHeader ( ) ; char [ ] dest = new char [ 116 ] ; char [ ] src = header . getDescription ( ) . toCharArray ( ) ; System . arraycopy ( src , 0 , dest , 0 , src . length ) ; byte [ ] endianIndicator = header . getEndianIndicator ( ) ; ByteBuffer buf = ByteBuffer . allocateDirect ( dest . length * 2 + 2 + endianIndicator . length ) ; for ( int i = 0 ; i < dest . length ; i ++ ) { buf . put ( ( byte ) dest [ i ] ) ; } buf . position ( buf . position ( ) + 8 ) ; int version = header . getVersion ( ) ; buf . put ( ( byte ) ( version > > 8 ) ) ; buf . put ( ( byte ) version ) ; buf . put ( endianIndicator ) ; buf . flip ( ) ; channel . write ( buf ) ; }
Writes MAT-file header into <code>OutputStream</code>
@param os <code>OutputStream</code>
@throws IOException