## org.red5.io.flv.impl
Class FLVWriter

    java.lang.Object
      org.red5.io.flv.impl.FLVWriter

All Implemented Interfaces:
  ITagWriter

    public class FLVWriter

extends Object
implements ITagWriter

A Writer is used to write the contents of a FLV file

Author:
  The Red5 Project (red5@osflash.org), Dominick Accattato (daccattato@gmail.com), Luke Hubbard, Codegent Ltd (luke@codegent.com), Tiago Jacobs (tiago@imdt.com.br)

Constructor Summary
`FLVWriter(File file, boolean append)` Creates writer implementation with given file and last tag FLV.java uses this constructor so we have access to the file object
`FLVWriter(FileOutputStream fos, boolean append)` Creates writer implementation with given file output stream and last tag

Method Summary
`void` `close()` Closes a Writer
`long` `getBytesWritten()` Return the bytes written
`IStreamableFile` `getFile()` Return the file that is written.
`int` `getOffset()` Return the offset
`void` `setFLV(IFLV flv)` Setter for FLV object
`void` `setOffset(int offset)` Setter for offset
`void` `writeHeader()` Writes the header bytes
`boolean` `writeStream(byte[] b)` Write a Stream to disk using bytes
`boolean` `writeTag(byte type, IoBuffer data)` Write a Tag using bytes
`boolean` `writeTag(ITag tag)` Writes a Tag object

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FLVWriter

    public FLVWriter(FileOutputStream fos,
                     boolean append)

  Creates writer implementation with given file output stream and last tag

  Parameters:
    `fos` - File output stream
    `append` - true if append to existing file

### FLVWriter

    public FLVWriter(File file,
                     boolean append)

  Creates writer implementation with given file and last tag FLV.java uses this constructor so we have access to the file object

  Parameters:
    `file` - File output stream
    `append` - true if append to existing file

Method Detail

### writeHeader

    public void writeHeader()
                     throws IOException

  Writes the header bytes

  Specified by:
    `writeHeader` in interface `ITagWriter`
  Throws:
    `IOException` - Any I/O exception

### getFile

    public IStreamableFile getFile()

  Return the file that is written.

  Specified by:
    `getFile` in interface `ITagWriter`
  Returns:
    the File to be written

### setFLV

    public void setFLV(IFLV flv)

  Setter for FLV object

  Parameters:
    `flv` - FLV source

### getOffset

    public int getOffset()

  Return the offset

  Specified by:
    `getOffset` in interface `ITagWriter`
  Returns:
    Offset value

### setOffset

    public void setOffset(int offset)

  Setter for offset

  Parameters:
    `offset` - Value to set for offset

### getBytesWritten

    public long getBytesWritten()

  Return the bytes written

  Specified by:
    `getBytesWritten` in interface `ITagWriter`
  Returns:
    Number of bytes written

### writeTag

    public boolean writeTag(ITag tag)
                     throws IOException

  Writes a Tag object

  Specified by:
    `writeTag` in interface `ITagWriter`
  Parameters:
    `tag` - Tag to write
  Returns:
    `true` on success, `false` otherwise
  Throws:
    `IOException` - I/O exception

### writeTag

    public boolean writeTag(byte type,
                            IoBuffer data)
                     throws IOException

  Write a Tag using bytes

  Specified by:
    `writeTag` in interface `ITagWriter`
  Parameters:
    `type` - Tag type
    `data` - Byte data
  Returns:
    `true` on success, `false` otherwise
  Throws:
    `IOException` - I/O exception

### close

    public void close()

  Closes a Writer

  Specified by:
    `close` in interface `ITagWriter`

### writeStream

    public boolean writeStream(byte[] b)

  Write a Stream to disk using bytes

  Specified by:
    `writeStream` in interface `ITagWriter`
  Parameters:
    `b` - Array of bytes to write
  Returns:
    `true` on success, `false` otherwise

Copyright © 2006-2010 The Red5 Project