Package jcifs.smb
Class SmbFileOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- jcifs.smb.SmbFileOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
SmbPipeOutputStream
public class SmbFileOutputStream extends OutputStream
ThisOutputStream
can write bytes to a file on an SMB file server.
-
-
Constructor Summary
Constructors Constructor Description SmbFileOutputStream(SmbFile file)
Creates anOutputStream
for writing bytes to a file on an SMB server represented by theSmbFile
parameter.SmbFileOutputStream(SmbFile file, boolean append)
Creates anOutputStream
for writing bytes to a file on an SMB server addressed by theSmbFile
parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this output stream and releases any system resources associated with it.protected jcifs.smb.SmbFileHandleImpl
ensureOpen()
protected jcifs.smb.SmbTreeHandleImpl
ensureTreeConnected()
protected void
init(jcifs.smb.SmbTreeHandleImpl th)
boolean
isOpen()
void
open()
Ensures that the file descriptor is openendvoid
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
-
-
-
-
Constructor Detail
-
SmbFileOutputStream
public SmbFileOutputStream(SmbFile file) throws SmbException
Creates anOutputStream
for writing bytes to a file on an SMB server represented by theSmbFile
parameter. SeeSmbFile
for a detailed description and examples of the smb URL syntax.- Parameters:
file
- AnSmbFile
specifying the file to write to- Throws:
SmbException
-
SmbFileOutputStream
public SmbFileOutputStream(SmbFile file, boolean append) throws SmbException
Creates anOutputStream
for writing bytes to a file on an SMB server addressed by theSmbFile
parameter. SeeSmbFile
for 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
- AnSmbFile
representing the file to write toappend
- Append to the end of file- Throws:
SmbException
-
-
Method Detail
-
init
protected final void init(jcifs.smb.SmbTreeHandleImpl th) throws CIFSException
- Parameters:
th
-- Throws:
SmbException
CIFSException
-
open
public void open() throws CIFSException
Ensures that the file descriptor is openend- Throws:
CIFSException
-
close
public void close() throws IOException
Closes this output stream and releases any system resources associated with it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- 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 classOutputStream
- 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 classOutputStream
- Throws:
IOException
- if a network error occurs
-
isOpen
public boolean isOpen()
- Returns:
- whether the stream is open
-
ensureOpen
protected jcifs.smb.SmbFileHandleImpl ensureOpen() throws CIFSException
- Throws:
CIFSException
-
ensureTreeConnected
protected jcifs.smb.SmbTreeHandleImpl ensureTreeConnected() throws CIFSException
- Throws:
CIFSException
-
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 classOutputStream
- Parameters:
b
- The array- 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
-off
-len
-flags
-- Throws:
IOException
-
-