public class SMBInputStream extends InputStream
The SMBInputStream class provides a standard InputStream interface to a remote file.
The class may be used with other I/O stream classes such as InputStreamReader, DataInputStream etc.
Note: It is not necessary to use a BufferedInputStream or BufferedReader class with the SMBInputStream as the underlying network connection will usually buffer 4Kb of data, up to a maximum of 64Kb.
Example use of the SMBInputStream class
PCShare shr = new PCShare ( "\\\\TEST\\C\\");
DiskSession sess = SessionFactory.OpenDisk ( shr);
SMBInputStream in = sess.OpenInputStream ( "DATAFILE.IN", AccessMode.ReadOnly);
LineNumberReader lnRdr = new LineNumberReader ( new InputStreamReader ( in));
String inRec = null;
while (( inRec = lnRdr.readLine ()) != null)
System.out.println ( lnRdr.getLineNumber () + ": " + inRec);
in.close ();
Modifier | Constructor and Description |
---|---|
protected |
SMBInputStream(SMBFile sfile)
Construct an SMB input stream attached to the specified SMB file.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Return the number of bytes that can be read from this input stream without blocking.
|
void |
close()
Close the input stream and release any system resources associated with the stream.
|
SMBFile |
File()
Return a reference to the associated SMBFile object.
|
void |
mark(int readLimit)
Mark the current file position
|
boolean |
markSupported()
Determine if mark is supported
|
int |
read()
Read a byte of data from the input stream.
|
int |
read(byte[] buf,
int off,
int len)
Read a block of bytes from the input stream.
|
void |
reset()
Reset the file pointer to the previous marked position
|
int |
skip(int n)
Skip over a number of bytes in the input stream.
|
read, skip
protected SMBInputStream(SMBFile sfile)
sfile
- SMBFile that this input stream is associated with.public int available() throws IOException
available
in class InputStream
IOException
- If an I/O error occurs.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
- If an I/O error occurs.public final SMBFile File()
public int read() throws IOException
read
in class InputStream
IOException
- If an I/O error occurs.public int read(byte[] buf, int off, int len) throws IOException
read
in class InputStream
buf
- The buffer to read the data into.off
- The start offset to place the received data.len
- The maximum number of bytes to read.IOException
- If an I/O error occurs.public int skip(int n) throws IOException
n
- Number of bytes to skip.IOException
- If an I/O error occurs.public void mark(int readLimit)
mark
in class InputStream
readLimit
- intpublic boolean markSupported()
markSupported
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
Copyright © 2005–2018 Alfresco Software. All rights reserved.