Package jcifs.smb

# Class SmbFileOutputStream

java.lang.Object
java.io.OutputStream
jcifs.smb.SmbFileOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

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

## Constructor Summary

Constructors
Constructor
Description
`SmbFileOutputStream(String url)`
Creates an `OutputStream` for writing to a file on an SMB server addressed by the URL parameter.
`SmbFileOutputStream(String url, boolean append)`
Creates an `OutputStream` for writing bytes to a file on an SMB server addressed by the URL parameter.
`SmbFileOutputStream(String url, int shareAccess)`
Creates an `OutputStream` for writing bytes to a file on an SMB server addressed by the `SmbFile` parameter.
`SmbFileOutputStream(SmbFile file)`
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`
`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.

### 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(String url) throws SmbException, MalformedURLException, UnknownHostException
Creates an `OutputStream` for writing to a file on an SMB server addressed by the URL parameter. See `SmbFile` 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`
  `MalformedURLException`
  `UnknownHostException`

### SmbFileOutputStream

public SmbFileOutputStream(SmbFile file) throws SmbException, MalformedURLException, UnknownHostException
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`
  `MalformedURLException`
  `UnknownHostException`

### SmbFileOutputStream

public SmbFileOutputStream(String url, boolean append) throws SmbException, MalformedURLException, UnknownHostException
Creates an `OutputStream` for writing bytes to a file on an SMB server addressed by the URL 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:
  `url` - An smb URL string representing the file to write to
  `append` - Append to the end of file
Throws:
  `SmbException`
  `MalformedURLException`
  `UnknownHostException`

### SmbFileOutputStream

public SmbFileOutputStream(SmbFile file, boolean append) throws SmbException, MalformedURLException, UnknownHostException
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`
  `MalformedURLException`
  `UnknownHostException`

### SmbFileOutputStream

public SmbFileOutputStream(String url, int shareAccess) throws SmbException, MalformedURLException, UnknownHostException
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.

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. The `FILE_SHARE_READ`, `FILE_SHARE_WRITE`, and `FILE_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 to
  `shareAccess` - File sharing flag: `SmbFile.FILE_NOSHARE` or any combination of `SmbFile.FILE_READ`, `SmbFile.FILE_WRITE`, and `SmbFile.FILE_DELETE`
Throws:
  `SmbException`
  `MalformedURLException`
  `UnknownHostException`

## Method Details

### 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()

### 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
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.

Throws:
  `IOException`