java.lang.Object
java.io.OutputStream
org.codelibs.jcifs.smb.impl.SmbFileOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
SmbPipeOutputStream
This
OutputStream can write bytes to a file on an SMB file server.-
Constructor Summary
ConstructorsConstructorDescriptionSmbFileOutputStream(SmbFile file) Creates anOutputStreamfor writing bytes to a file on an SMB server represented by theSmbFileparameter.SmbFileOutputStream(SmbFile file, boolean append) Creates anOutputStreamfor writing bytes to a file on an SMB server addressed by theSmbFileparameter. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this output stream and releases any system resources associated with it.protected org.codelibs.jcifs.smb.impl.SmbFileHandleImplEnsures that the file handle is open and returns it.protected org.codelibs.jcifs.smb.impl.SmbTreeHandleImplEnsures that the tree connection is established.protected final voidinit(org.codelibs.jcifs.smb.impl.SmbTreeHandleImpl th) Initialize the output stream with the tree handle configuration.booleanisOpen()Tests whether the output stream is currently open.voidopen()Ensures that the file descriptor is openendvoidwrite(byte[] b) Writes b.length bytes from the specified byte array to this file output stream.voidwrite(byte[] b, int off, int len) Writes len bytes from the specified byte array starting at offset off to this file output stream.voidwrite(int b) Writes the specified byte to this file output stream.voidwriteDirect(byte[] b, int off, int len, int flags) Just bypasses TransWaitNamedPipe - used by DCERPC bind.Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Constructor Details
-
SmbFileOutputStream
Creates anOutputStreamfor writing bytes to a file on an SMB server represented by theSmbFileparameter. SeeSmbFilefor a detailed description and examples of the smb URL syntax.- Parameters:
file- AnSmbFilespecifying the file to write to- Throws:
SmbException- if an SMB error occurs
-
SmbFileOutputStream
Creates anOutputStreamfor writing bytes to a file on an SMB server addressed by theSmbFileparameter. SeeSmbFilefor a detailed description and examples of the smb URL syntax. If the second argument istrue, then bytes will be written to the end of the file rather than the beginning.- Parameters:
file- AnSmbFilerepresenting the file to write toappend- Append to the end of file- Throws:
SmbException- if an SMB error occurs
-
-
Method Details
-
init
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
Ensures that the file descriptor is openend- Throws:
CIFSException- if an error occurs opening the file
-
close
Closes this output stream and releases any system resources associated with it.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if a network error occurs
-
write
Writes the specified byte to this file output stream.- Specified by:
writein classOutputStream- Throws:
IOException- if a network error occurs
-
write
Writes b.length bytes from the specified byte array to this file output stream.- Overrides:
writein classOutputStream- 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
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
Ensures that the tree connection is established.- Returns:
- the tree handle
- Throws:
CIFSException- if an error occurs connecting to the tree
-
write
Writes len bytes from the specified byte array starting at offset off to this file output stream.- Overrides:
writein classOutputStream- Parameters:
b- The arrayoff- the start offset in the datalen- the number of bytes to write- Throws:
IOException- if a network error occurs
-
writeDirect
Just bypasses TransWaitNamedPipe - used by DCERPC bind.- Parameters:
b- the byte array containing the data to writeoff- the start offset in the datalen- the number of bytes to writeflags- write operation flags- Throws:
IOException- if an I/O error occurs
-