org.gnu.jcifs
Class CifsFileOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--org.gnu.jcifs.CifsFileOutputStream

public class CifsFileOutputStream
extends java.io.OutputStream

The class implements a CIFS output stream. The data is written into a buffer, and then written to the underlying stream if the buffer reaches its capacity, the buffer output stream is closed, or the buffer output stream is explicity flushed. The default buffer size is 2048. The system property org.gnu.jcifs.io.bufsize specifies the buffer size.

The implementation was borrowed from BufferedInputStream.

Since:
1.0

Constructor Summary
CifsFileOutputStream(CifsDisk disk, java.lang.String file, boolean append)
          Creates a file output stream to write to the specified file
CifsFileOutputStream(CifsFile file, boolean append)
          Creates a file output stream to write to the specified file
CifsFileOutputStream(java.lang.String sessionname, java.lang.String file, boolean append)
          Creates a file output stream to write to the specified file
 
Method Summary
 void close()
          Closes this output stream and releases any system resources associated with the stream.
 void finalize()
           
 void flush()
          Flushes this buffered output stream.
 CifsDisk getDisk()
          Returns the disk on which the file resides
protected  void open(java.lang.String file, CifsDisk disk, boolean append)
           
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this buffered output stream.
 void write(int b)
          Writes the specified byte to this buffered output stream.
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CifsFileOutputStream

public CifsFileOutputStream(CifsDisk disk,
                            java.lang.String file,
                            boolean append)
                     throws java.io.IOException
Creates a file output stream to write to the specified file
Parameters:
disk - disk
file - relativ to share
append - if true append data otherwise overwrite
Throws:
java.io.IOException - if an I/O error occurs.

CifsFileOutputStream

public CifsFileOutputStream(java.lang.String sessionname,
                            java.lang.String file,
                            boolean append)
                     throws java.io.IOException
Creates a file output stream to write to the specified file
Parameters:
sessioname - disk session name
file - file name( Syntax: /diskname/path or diskname:\path )
append - if true append data otherwise overwrite
Throws:
java.io.IOException - if an I/O error occurs.

CifsFileOutputStream

public CifsFileOutputStream(CifsFile file,
                            boolean append)
                     throws java.io.IOException
Creates a file output stream to write to the specified file
Parameters:
file - CIFS file
append - if true append data otherwise overwrite
Throws:
java.io.IOException - if an I/O error occurs.
Method Detail

open

protected void open(java.lang.String file,
                    CifsDisk disk,
                    boolean append)
             throws java.io.IOException

getDisk

public CifsDisk getDisk()
                 throws java.io.IOException
Returns the disk on which the file resides
Returns:
CifsDisk disk object
Throws:
java.io.IOException - if file is closed

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this buffered output stream.
Overrides:
write in class java.io.OutputStream
Parameters:
b - the byte to be written.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to this buffered output stream.

Ordinarily this method stores bytes from the given array into this stream's buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large as this stream's buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.

flush

public void flush()
           throws java.io.IOException
Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - if an I/O error occurs.

close

public void close()
           throws java.io.IOException
Closes this output stream and releases any system resources associated with the stream.
Overrides:
close in class java.io.OutputStream

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object