com.starla.smb
Class SMBInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--com.starla.smb.SMBInputStream

public class SMBInputStream
extends java.io.InputStream

SMB input stream class.

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\\");
SMBDiskSession sess = SMBSessionFactory.OpenDisk ( shr);
SMBInputStream in = sess.OpenInputStream ( "DATAFILE.IN", SMBAccessMode.ReadOnly);
LineNumberReader lnRdr = new LineNumberReader ( new InputStreamReader ( in));
String inRec = null;
while (( inRec = lnRdr.readLine ()) != null)
  System.out.println ( lnRdr.getLineNumber () + ": " + inRec);
in.close ();


Method Summary
 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.
 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.
 int skip(int n)
          Skip over a number of bytes in the input stream.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

available

public int available()
              throws java.io.IOException
Return the number of bytes that can be read from this input stream without blocking.
Returns:
Number of bytes that can be read without the input stream blocking.
Throws:
java.io.IOException - If an I/O error occurs.
Overrides:
available in class java.io.InputStream

close

public void close()
           throws java.io.IOException
Close the input stream and release any system resources associated with the stream.
Throws:
java.io.IOException - If an I/O error occurs.
Overrides:
close in class java.io.InputStream

File

public final SMBFile File()
Return a reference to the associated SMBFile object.
Returns:
SMBFile associated with this input stream.

read

public int read()
         throws java.io.IOException
Read a byte of data from the input stream.
Returns:
The next byte of data, or -1 if the end of file has been reached.
Throws:
java.io.IOException - If an I/O error occurs.
Overrides:
read in class java.io.InputStream

read

public int read(byte[] buf,
                int off,
                int len)
         throws java.io.IOException
Read a block of bytes from the input stream.
Parameters:
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.
Returns:
The number of bytes read into the buffer, or -1 if the end of file has been reached.
Throws:
java.io.IOException - If an I/O error occurs.
Overrides:
read in class java.io.InputStream

skip

public int skip(int n)
         throws java.io.IOException
Skip over a number of bytes in the input stream.
Parameters:
n - Number of bytes to skip.
Returns:
The actual number of bytes skipped.
Throws:
java.io.IOException - If an I/O error occurs.