net.sf.hermesftp.streams
Class RafOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.sf.hermesftp.streams.RafOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, RecordWriteSupport

public class RafOutputStream
extends java.io.OutputStream
implements RecordWriteSupport

Wrapper class for writing to a RandomAccessFile through the OutputStream abstraction.

Author:
Lars Behnke

Constructor Summary
RafOutputStream(java.io.File file)
          Constructor.
RafOutputStream(java.io.File file, boolean append)
          Constructor.
RafOutputStream(java.io.File file, long offset)
          Constructor.
 
Method Summary
 void close()
          
 void write(byte[] b)
          
 void write(byte[] b, int off, int len)
          
 void write(int b)
          
 void writeRecord(byte[] data, boolean eof)
          Writes out a whole record.
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.hermesftp.streams.RecordWriteSupport
flush
 

Constructor Detail

RafOutputStream

public RafOutputStream(java.io.File file)
Constructor.

Parameters:
file - The output file;

RafOutputStream

public RafOutputStream(java.io.File file,
                       long offset)
Constructor.

Parameters:
file - The output file;
offset - The number of bytes to be skipped, when writing to the file.

RafOutputStream

public RafOutputStream(java.io.File file,
                       boolean append)
Constructor.

Parameters:
file - The output file;
append - Indication whether the data is to be appended to the output file.
Method Detail

write

public void write(int b)
           throws java.io.IOException

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

writeRecord

public void writeRecord(byte[] data,
                        boolean eof)
                 throws java.io.IOException
Writes out a whole record.

Specified by:
writeRecord in interface RecordWriteSupport
Parameters:
data - The record data.
eof - True, if last record is passed.
Throws:
java.io.IOException - Thrown if writing fails.

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.