Module jcifs

Class SmbFileOutputStream

java.lang.Object
java.io.OutputStream
org.codelibs.jcifs.smb.impl.SmbFileOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Direct Known Subclasses:
SmbPipeOutputStream

public class SmbFileOutputStream extends OutputStream
This OutputStream can write bytes to a file on an SMB file server.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an OutputStream for writing bytes to a file on an SMB server represented by the SmbFile parameter.
    SmbFileOutputStream(SmbFile file, boolean append)
    Creates an OutputStream for writing bytes to a file on an SMB server addressed by the SmbFile parameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this output stream and releases any system resources associated with it.
    protected org.codelibs.jcifs.smb.impl.SmbFileHandleImpl
    Ensures that the file handle is open and returns it.
    protected org.codelibs.jcifs.smb.impl.SmbTreeHandleImpl
    Ensures that the tree connection is established.
    protected final void
    init(org.codelibs.jcifs.smb.impl.SmbTreeHandleImpl th)
    Initialize the output stream with the tree handle configuration.
    boolean
    Tests whether the output stream is currently open.
    void
    Ensures that the file descriptor is openend
    void
    write(byte[] b)
    Writes b.length bytes from the specified byte array to this file output stream.
    void
    write(byte[] b, int off, int len)
    Writes len bytes from the specified byte array starting at offset off to this file output stream.
    void
    write(int b)
    Writes the specified byte to this file output stream.
    void
    writeDirect(byte[] b, int off, int len, int flags)
    Just bypasses TransWaitNamedPipe - used by DCERPC bind.

    Methods inherited from class java.io.OutputStream

    flush, nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SmbFileOutputStream

      public SmbFileOutputStream(SmbFile file) throws SmbException
      Creates an OutputStream for writing bytes to a file on an SMB server represented by the SmbFile parameter. See SmbFile for a detailed description and examples of the smb URL syntax.
      Parameters:
      file - An SmbFile specifying the file to write to
      Throws:
      SmbException - if an SMB error occurs
    • SmbFileOutputStream

      public SmbFileOutputStream(SmbFile file, boolean append) throws SmbException
      Creates an OutputStream for writing bytes to a file on an SMB server addressed by the SmbFile parameter. See SmbFile for a detailed description and examples of the smb URL syntax. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.
      Parameters:
      file - An SmbFile representing the file to write to
      append - Append to the end of file
      Throws:
      SmbException - if an SMB error occurs
  • Method Details

    • init

      protected final void init(org.codelibs.jcifs.smb.impl.SmbTreeHandleImpl th) throws CIFSException
      Initialize the output stream with the tree handle configuration.
      Parameters:
      th - the tree handle to use for configuration
      Throws:
      CIFSException - if an error occurs during initialization
    • open

      public void open() throws CIFSException
      Ensures that the file descriptor is openend
      Throws:
      CIFSException - if an error occurs opening the file
    • close

      public void close() throws IOException
      Closes this output stream and releases any system resources associated with it.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException - if a network error occurs
    • write

      public void write(int b) throws IOException
      Writes the specified byte to this file output stream.
      Specified by:
      write in class OutputStream
      Throws:
      IOException - if a network error occurs
    • write

      public void write(byte[] b) throws IOException
      Writes b.length bytes from the specified byte array to this file output stream.
      Overrides:
      write in class OutputStream
      Throws:
      IOException - if a network error occurs
    • isOpen

      public boolean isOpen()
      Tests whether the output stream is currently open.
      Returns:
      whether the stream is open
    • ensureOpen

      protected org.codelibs.jcifs.smb.impl.SmbFileHandleImpl ensureOpen() throws CIFSException
      Ensures that the file handle is open and returns it.
      Returns:
      the open file handle
      Throws:
      CIFSException - if an error occurs opening the file
    • ensureTreeConnected

      protected org.codelibs.jcifs.smb.impl.SmbTreeHandleImpl ensureTreeConnected() throws CIFSException
      Ensures that the tree connection is established.
      Returns:
      the tree handle
      Throws:
      CIFSException - if an error occurs connecting to the tree
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Writes len bytes from the specified byte array starting at offset off to this file output stream.
      Overrides:
      write in class OutputStream
      Parameters:
      b - The array
      off - the start offset in the data
      len - the number of bytes to write
      Throws:
      IOException - if a network error occurs
    • writeDirect

      public void writeDirect(byte[] b, int off, int len, int flags) throws IOException
      Just bypasses TransWaitNamedPipe - used by DCERPC bind.
      Parameters:
      b - the byte array containing the data to write
      off - the start offset in the data
      len - the number of bytes to write
      flags - write operation flags
      Throws:
      IOException - if an I/O error occurs