Class SmbFileOutputStream
java.lang.Object
java.io.OutputStream
jcifs.smb.SmbFileOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
This
OutputStream can write bytes to a file on an SMB file server.-
Constructor Summary
ConstructorsConstructorDescriptionCreates anOutputStreamfor writing to a file on an SMB server addressed by the URL parameter.SmbFileOutputStream(String url, boolean append) Creates anOutputStreamfor writing bytes to a file on an SMB server addressed by the URL parameter.SmbFileOutputStream(String url, int shareAccess) Creates anOutputStreamfor writing bytes to a file on an SMB server addressed by theSmbFileparameter.SmbFileOutputStream(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.booleanisOpen()voidwrite(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 OutputStream
flush, nullOutputStream
-
Constructor Details
-
SmbFileOutputStream
public SmbFileOutputStream(String url) throws SmbException, MalformedURLException, UnknownHostException Creates anOutputStreamfor writing to a file on an SMB server addressed by the URL parameter. SeeSmbFilefor a detailed description and examples of the smb URL syntax.- Parameters:
url- An smb URL string representing the file to write to- Throws:
SmbExceptionMalformedURLExceptionUnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(SmbFile file) throws SmbException, MalformedURLException, UnknownHostException 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:
SmbExceptionMalformedURLExceptionUnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(String url, boolean append) throws SmbException, MalformedURLException, UnknownHostException Creates anOutputStreamfor writing bytes to a file on an SMB server addressed by the URL parameter. 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:
url- An smb URL string representing the file to write toappend- Append to the end of file- Throws:
SmbExceptionMalformedURLExceptionUnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(SmbFile file, boolean append) throws SmbException, MalformedURLException, UnknownHostException 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:
SmbExceptionMalformedURLExceptionUnknownHostException
-
SmbFileOutputStream
public SmbFileOutputStream(String url, int shareAccess) throws SmbException, MalformedURLException, UnknownHostException 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.The second parameter specifies how the file should be shared. If
SmbFile.FILE_NO_SHAREis 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_DELETEmay 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_NOSHAREor any combination ofSmbFile.FILE_READ,SmbFile.FILE_WRITE, andSmbFile.FILE_DELETE- Throws:
SmbExceptionMalformedURLExceptionUnknownHostException
-
-
Method Details
-
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() -
write
Writes len bytes from the specified byte array starting at offset off to this file output stream.- Overrides:
writein classOutputStream- Parameters:
b- The array- Throws:
IOException- if a network error occurs
-
writeDirect
Just bypasses TransWaitNamedPipe - used by DCERPC bind.- Throws:
IOException
-