net.sf.hermesftp.streams
Class BlockModeOutputStream

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

public class BlockModeOutputStream
extends java.io.OutputStream
implements BlockModeConstants, RecordWriteSupport

In the case of a file being sent with file-structure to a record-oriented host, there exists the question of what criteria the host should use to divide the file into records which can be processed locally. If this division is necessary, an FTP implementation should use the end-of-line sequence, CRLF for ASCII, or NewLine (0x25) for EBCDIC text files, as the delimiter. If an FTP implementation adopts this technique, it must be prepared to reverse the transformation if the file is retrieved with file-structure.

Author:
Lars Behnke

Field Summary
 
Fields inherited from interface net.sf.hermesftp.streams.BlockModeConstants
DESC_CODE_EOF, DESC_CODE_EOR, DESC_CODE_ERR, DESC_CODE_REST
 
Constructor Summary
BlockModeOutputStream(java.io.OutputStream os)
          Constructor.
BlockModeOutputStream(java.io.OutputStream os, int blockSize)
          Constructor.
 
Method Summary
 void close()
          
 void finalizeRecord(boolean eof)
          Flushes the last dataset.
 void flush()
          Flushes any buffered record data.
 void write(int b)
          
 void writeRecord(byte[] record, boolean eof)
          Writes a complete record and marks the transfer optionally with EOF.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockModeOutputStream

public BlockModeOutputStream(java.io.OutputStream os)
Constructor.

Parameters:
os - The nested output stream.

BlockModeOutputStream

public BlockModeOutputStream(java.io.OutputStream os,
                             int blockSize)
Constructor.

Parameters:
os - The output stream.
blockSize - The blocksize.
Method Detail

writeRecord

public void writeRecord(byte[] record,
                        boolean eof)
                 throws java.io.IOException
Writes a complete record and marks the transfer optionally with EOF.

Specified by:
writeRecord in interface RecordWriteSupport
Parameters:
record - The data to be transmitted.
eof - True, if the transfer is complete.
Throws:
java.io.IOException - If writing the data fails or the file was previously finalized.

write

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

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

flush

public void flush()
           throws java.io.IOException
Flushes any buffered record data.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in interface RecordWriteSupport
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - Thrown if IO fails.

finalizeRecord

public void finalizeRecord(boolean eof)
                    throws java.io.IOException
Flushes the last dataset. Block mode transfer requires setting EOF explicitly.

Parameters:
eof - True, if end of file.
Throws:
java.io.IOException - When 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.