Package jcifs.smb
Class SmbFileOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- jcifs.smb.SmbFileOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class SmbFileOutputStream extends java.io.OutputStream
ThisOutputStream
can write bytes to a file on an SMB file server.
-
-
Constructor Summary
Constructors Constructor Description SmbFileOutputStream(java.lang.String url)
Creates anOutputStream
for writing to a file on an SMB server addressed by the URL parameter.SmbFileOutputStream(java.lang.String url, boolean append)
Creates anOutputStream
for writing bytes to a file on an SMB server addressed by the URL parameter.SmbFileOutputStream(java.lang.String url, int shareAccess)
Creates anOutputStream
for writing bytes to a file on an SMB server addressed by theSmbFile
parameter.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.boolean
isOpen()
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.
-
-
-
Constructor Detail
-
SmbFileOutputStream
public SmbFileOutputStream(java.lang.String url) throws SmbException, java.net.MalformedURLException, java.net.UnknownHostException
Creates anOutputStream
for writing to a file on an SMB server addressed by the URL parameter. SeeSmbFile
for a detailed description and examples of the smb URL syntax.- Parameters:
url
- An smb URL string representing the file to write to- Throws:
SmbException
java.net.MalformedURLException
java.net.UnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(SmbFile file) throws SmbException, java.net.MalformedURLException, java.net.UnknownHostException
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
java.net.MalformedURLException
java.net.UnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(java.lang.String url, boolean append) throws SmbException, java.net.MalformedURLException, java.net.UnknownHostException
Creates anOutputStream
for writing bytes to a file on an SMB server addressed by the URL 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:
url
- An smb URL string representing the file to write toappend
- Append to the end of file- Throws:
SmbException
java.net.MalformedURLException
java.net.UnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(SmbFile file, boolean append) throws SmbException, java.net.MalformedURLException, java.net.UnknownHostException
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
java.net.MalformedURLException
java.net.UnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(java.lang.String url, int shareAccess) throws SmbException, java.net.MalformedURLException, java.net.UnknownHostException
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.The second parameter specifies how the file should be shared. If
SmbFile.FILE_NO_SHARE
is specified the client will have exclusive access to the file. An additional open command from jCIFS or another application will fail with the "file is being accessed by another process" error. TheFILE_SHARE_READ
,FILE_SHARE_WRITE
, andFILE_SHARE_DELETE
may be combined with the bitwise OR '|' to specify that other peocesses may read, write, and/or delete the file while the jCIFS user has the file open.- Parameters:
url
- An smb URL representing the file to write toshareAccess
- File sharing flag:SmbFile.FILE_NOSHARE
or any combination ofSmbFile.FILE_READ
,SmbFile.FILE_WRITE
, andSmbFile.FILE_DELETE
- Throws:
SmbException
java.net.MalformedURLException
java.net.UnknownHostException
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Closes this output stream and releases any system resources associated with it.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
- if a network error occurs
-
write
public void write(int b) throws java.io.IOException
Writes the specified byte to this file output stream.- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
- if a network error occurs
-
write
public void write(byte[] b) throws java.io.IOException
Writes b.length bytes from the specified byte array to this file output stream.- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
- if a network error occurs
-
isOpen
public boolean isOpen()
-
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 file output stream.- Overrides:
write
in classjava.io.OutputStream
- Parameters:
b
- The array- Throws:
java.io.IOException
- if a network error occurs
-
writeDirect
public void writeDirect(byte[] b, int off, int len, int flags) throws java.io.IOException
Just bypasses TransWaitNamedPipe - used by DCERPC bind.- Throws:
java.io.IOException
-
-