public class SMBOutputStream
extends java.io.OutputStream
The SMBOutputStream class provides a standard OutputStream interface to an existing remote file, or can be used to create a new remote file.
The class may be used with other I/O stream classes such as PrintWriter, DataOutputStream etc.
Note: It is not necessary to use a BufferedOutputStream or BufferedWriter class with the SMBOutputStream as the underlying network connection will usually buffer 4Kb of data, up to a maximum of 64Kb.
Example use of the SMBOutputStream class
PCShare shr = new PCShare ( "\\\\TEST\\C\\");
DiskSession sess = SessionFactory.OpenDisk ( shr);
SMBOutputStream out = sess.OpenOutputStream ( "DATAFILE.OUT", AccessMode.WriteOnly);
PrintWriter pWrt = new PrintWriter ( out, false);
for ( int i = 0; i < 20; i++)
pWrt.println ( "Record " + i);
pWrt.flush ();
out.close ();
Modifier | Constructor and Description |
---|---|
protected |
SMBOutputStream(SMBFile sfile)
Construct an SMB output stream attached to the specified SMB file
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this output stream and release any system resources associated with the stream.
|
SMBFile |
File()
Return a reference to the associated SMBFile object.
|
void |
flush()
Flush this output stream, force any buffered data to be written out.
|
void |
write(byte[] buf,
int off,
int len)
Write the specified byte array to the output stream, starting at the specified offset within
the byte array.
|
void |
write(int byt)
Write the specified byte to this output stream.
|
protected SMBOutputStream(SMBFile sfile)
sfile
- SMBFile that this output stream is attached to.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
- If an I/O error occurs.public final SMBFile File()
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
- If an I/O error occurs.public void write(byte[] buf, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
buf
- Byte array containing the data to be output.off
- Offset within the buffer that the data starts.len
- Length of the data to be output.java.io.IOException
- If an I/O error occurs.public void write(int byt) throws java.io.IOException
write
in class java.io.OutputStream
byt
- Byte to be output to this stream.java.io.IOException
- If an I/O error occurs.Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.