format/src/main/java/com/github/sadikovi/riff/FileHeader.java
/**
   * Write header into output stream.
   * Stream is not closed after this operation is complete.
   * @param out output stream
   * @throws IOException
   */
Write header into output stream.
Stream is not closed after this operation is complete.
@param out output stream
@throws IOException
Write header into output stream . Stream is not closed after this operation is complete . @param out output stream @throws IOException
public void writeTo(FSDataOutputStream out) throws IOException {
    OutputBuffer buffer = new OutputBuffer();
    buffer.write(state);
    td.writeTo(buffer);
    if (properties == null) {
      buffer.writeInt(-1);
    } else {
      byte[] bytes = null;
      buffer.writeInt(properties.size());
      for (String key : properties.keySet()) {
        bytes = key.getBytes();
        buffer.writeInt(bytes.length);
        buffer.writeBytes(bytes);
        bytes = properties.get(key).getBytes();
        buffer.writeInt(bytes.length);
        buffer.writeBytes(bytes);
      }
    }
    buffer.align();
    LOG.debug("Write header content of {} bytes", buffer.bytesWritten());
    out.writeLong(((long) Riff.MAGIC << 32) + buffer.bytesWritten());
    buffer.writeExternal(out);
  }
public void writeTo ( FSDataOutputStream out ) throws IOException { OutputBuffer buffer = new OutputBuffer ( ) ; buffer . write ( state ) ; td . writeTo ( buffer ) ; if ( properties == null ) { buffer . writeInt ( - 1 ) ; } else { byte [ ] bytes = null ; buffer . writeInt ( properties . size ( ) ) ; for ( String key : properties . keySet ( ) ) { bytes = key . getBytes ( ) ; buffer . writeInt ( bytes . length ) ; buffer . writeBytes ( bytes ) ; bytes = properties . get ( key ) . getBytes ( ) ; buffer . writeInt ( bytes . length ) ; buffer . writeBytes ( bytes ) ; } } buffer . align ( ) ; LOG . debug ( "Write header content of {} bytes" , buffer . bytesWritten ( ) ) ; out . writeLong ( ( ( long ) Riff . MAGIC << 32 ) + buffer . bytesWritten ( ) ) ; buffer . writeExternal ( out ) ; }
Write header into output stream.
Write header into output stream .
// record file header // write properties map, size -1 means that properties is null // write key // write value // write magic 4 bytes + buffer length 4 bytes into output stream // write buffer data