javaFlacEncoder
Class FLACFileOutputStream

java.lang.Object
  extended by javaFlacEncoder.FLACFileOutputStream
All Implemented Interfaces:
FLACOutputStream

public class FLACFileOutputStream
extends java.lang.Object
implements FLACOutputStream

This class provides basic file output for writing from a FLACEncoder.

Author:
Preston Lacey

Constructor Summary
FLACFileOutputStream(java.lang.String filename)
          Constructor.
 
Method Summary
 boolean canSeek()
          Test whether this stream is seekable.
 long getPos()
          Get the current write position of this stream.
 boolean isValid()
          Get the status of this file stream(whether the file was successfully open or not).
 long seek(long pos)
          Attempt to seek to the given location within this stream.
 long size()
          Get the number of bytes that have been written in length! This takes into account seeking to different portions.
 void write(byte data)
          Write a byte to this stream.
 int write(byte[] data, int offset, int count)
          Write the given number of bytes from the byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FLACFileOutputStream

public FLACFileOutputStream(java.lang.String filename)
Constructor. Create a FLACFileOutputStream using the given filename. If file exists, file will be overwritten. Method isValid() should be used to ensure no errors occurred opening this file.

Parameters:
filename - file to connect to output stream.
Method Detail

isValid

public boolean isValid()
Get the status of this file stream(whether the file was successfully open or not).

Returns:
true if file was successfully opened, false otherwise.

seek

public long seek(long pos)
Attempt to seek to the given location within this stream. It is not guaranteed that all implementations can or will support seeking. Use the method canSeek()

Specified by:
seek in interface FLACOutputStream
Parameters:
pos - target position to seek to.
Returns:
current position after seek attempt.

write

public void write(byte data)
           throws java.io.IOException
Write a byte to this stream.

Specified by:
write in interface FLACOutputStream
Parameters:
data - byte to write.
Throws:
java.io.IOException - IOException will be raised if an error occurred while writing.

write

public int write(byte[] data,
                 int offset,
                 int count)
          throws java.io.IOException
Write the given number of bytes from the byte array. Return number of bytes written.

Specified by:
write in interface FLACOutputStream
Parameters:
data - array containing bytes to be written.
offset - start index of array to begin reading from.
count - number of bytes to write.
Returns:
number of bytes written.
Throws:
java.io.IOException - IOException upon a write error.

size

public long size()
Get the number of bytes that have been written in length! This takes into account seeking to different portions.

Specified by:
size in interface FLACOutputStream
Returns:
total length written.

canSeek

public boolean canSeek()
Test whether this stream is seekable.

Specified by:
canSeek in interface FLACOutputStream
Returns:
true if stream is seekable, false otherwise

getPos

public long getPos()
Get the current write position of this stream.

Specified by:
getPos in interface FLACOutputStream
Returns:
current write position.