Skip navigation links

Oracle Multimedia Java API Reference
11g Release 1 (11.1)

Part No. B28413-01


oracle.ord.media.jai.io
Class FileSeekableOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by oracle.ord.media.jai.io.SeekableOutputStream
          extended by oracle.ord.media.jai.io.FileSeekableOutputStream

All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class FileSeekableOutputStream
extends SeekableOutputStream

A SeekableOutputStream class that writes to a file whose original contents will be overwritten.


Constructor Summary
FileSeekableOutputStream(java.io.File file)
          Creates a FileSeekableOutputStream object that writes to a file.
FileSeekableOutputStream(java.lang.String name)
          Creates a FileSeekableOutputStream object that writes to a named file.

 

Method Summary
 void close()
          Closes the output stream and releases any resources associated with this stream.
 void flush()
          Flushes the output stream and forces any buffered output bytes to be written to the file.
 long getFilePointer()
          Returns the offset in the stream.
 long length()
          Returns the current length of the stream.
 void seek(long pos)
          Sets the file-pointer offset, measured from the beginning of this stream, at which the next write operation will occur.
 void truncate(long len)
          Truncates the stream to the specified length.
 void write(byte[] b)
          Writes all bytes in the specified byte array to the file.
 void write(byte[] b, int off, int len)
          Writes the specified number of bytes from the specified byte array to the file.
 void write(int b)
          Writes the specified byte to the file.

 

Methods inherited from class oracle.ord.media.jai.io.SeekableOutputStream
wrapOutputStream

 

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

 

Constructor Detail

FileSeekableOutputStream

public FileSeekableOutputStream(java.io.File file)
                         throws java.io.IOException,
                                java.io.FileNotFoundException
Creates a FileSeekableOutputStream object that writes to a file.
Parameters:
file - the file to which the data will be written.
Throws:
java.io.FileNotFoundException - if the file does not exist.
java.io.IOException - if an IO error occurs or if the value of the file parameter is null.

FileSeekableOutputStream

public FileSeekableOutputStream(java.lang.String name)
                         throws java.io.IOException,
                                java.io.FileNotFoundException
Creates a FileSeekableOutputStream object that writes to a named file.
Parameters:
name - the name of the system-dependent file.
Throws:
java.io.FileNotFoundException - if the file does not exist.
java.io.IOException - if an IO error occurs or if the value of the name parameter is null.

Method Detail

length

public long length()
            throws java.io.IOException
Returns the current length of the stream.
Specified by:
length in class SeekableOutputStream
Throws:
java.io.IOException - if an IO error occurs.

getFilePointer

public long getFilePointer()
                    throws java.io.IOException
Returns the offset in the stream.
Specified by:
getFilePointer in class SeekableOutputStream
Throws:
java.io.IOException - if an IO error occurs.

seek

public void seek(long pos)
          throws java.io.IOException
Sets the file-pointer offset, measured from the beginning of this stream, at which the next write operation will occur.

The offset may be set beyond the end of the stream. Setting the offset beyond the end of the stream does not change the stream length; the stream length will change only by writing after the offset has been set beyond the end of the stream.

Specified by:
seek in class SeekableOutputStream
Parameters:
pos - the offset position, measured in bytes from the beginning of the stream, at which to set the file pointer.
Throws:
java.io.IOException - if the value of the pos parameter is less than zero or if an IO error occurs.

truncate

public void truncate(long len)
              throws java.io.IOException
Truncates the stream to the specified length.
Specified by:
truncate in class SeekableOutputStream
Parameters:
len - the length of the stream, in bytes.
Throws:
java.io.IOException - if the value of the len parameter is less than zero or larger than the stream length, or if an IO error occurs.

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to the file.
Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte to be written to the file. Only the low-order byte is written; the upper 24 bits are ignored.
Throws:
java.io.IOException - if an IO error occurs.

write

public void write(byte[] b)
           throws java.io.IOException
Writes all bytes in the specified byte array to the file.
Overrides:
write in class java.io.OutputStream
Parameters:
b - an array of bytes to be written to the file.
Throws:
java.io.IOException - if an IO error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes the specified number of bytes from the specified byte array to the file.
Overrides:
write in class java.io.OutputStream
Parameters:
b - the buffer containing the data to be written to the file.
off - the starting position for the offset in the buffer.
len - the number of bytes to write to the file.
Throws:
java.io.IOException - if an IO error occurs.

flush

public void flush()
           throws java.io.IOException
Flushes the output stream and forces any buffered output bytes to be written to the file.

There is little need to call this method until all the data has been written because the close method includes a call to the flush method.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - if an IO error occurs.

close

public void close()
           throws java.io.IOException
Closes the output stream and releases any resources associated with this stream. Before closing the stream, this method automatically calls the flush() method to write any buffered bytes to the stream.
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - if an IO error occurs.

Skip navigation links

Oracle Multimedia Java API Reference
11g Release 1 (11.1)

Part No. B28413-01


Copyright © 1999, 2007, Oracle. All rights reserved.