SSH Factory

com.jscape.inet.telnet
Class TelnetInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.jscape.inet.telnet.TelnetInputStream
All Implemented Interfaces:
java.io.Closeable

public class TelnetInputStream
extends java.io.InputStream

Specialised input stream used to interpret telnet commands in ASCII stream.


Constructor Summary
TelnetInputStream(Telnet tn, java.io.InputStream in)
          Creates a new TelnetInputStream object.
 
Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
 void flush()
          Reads until the amount of data available is greater than 0 bytes
 java.io.InputStream getStream()
          Returns underlying stream.
 void mark(int readlimit)
          Marks the current position in this input stream.
 boolean markSupported()
          Checks if mark is supported in this TelnetInputStream
 int read()
          Read data from telnet stream with escaping control characters.
 int read(byte[] b)
          Read data from telnet stream with escaping control characters.
 int read(byte[] b, int off, int len)
          Read data from telnet stream with escaping control characters.
 java.lang.String readBlock(java.lang.String[] lbr)
          Reads from the stream.
 java.lang.String readLine(java.lang.String[] lbr)
          Reads from the stream.
 void reset()
          Repositions this stream to the position at the time the mark method was last called on this input stream.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.
 int tread()
          Read data from telnet stream without escaping control characters.
 
Methods inherited from class java.io.InputStream
close
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TelnetInputStream

public TelnetInputStream(Telnet tn,
                         java.io.InputStream in)
Creates a new TelnetInputStream object.

Parameters:
tn - a Telnet
in - an InputStream
Method Detail

getStream

public java.io.InputStream getStream()
Returns underlying stream.

Returns:
an InputStream

read

public int read()
         throws java.io.IOException
Read data from telnet stream with escaping control characters.

Specified by:
read in class java.io.InputStream
Returns:
data read
Throws:
java.io.IOException - if an I/O related error occurs

tread

public int tread()
          throws java.io.IOException
Read data from telnet stream without escaping control characters.

Returns:
data read
Throws:
java.io.IOException - if an I/O related error occurs

read

public int read(byte[] b)
         throws java.io.IOException
Read data from telnet stream with escaping control characters.

Overrides:
read in class java.io.InputStream
Parameters:
b - buffer to read data from
Returns:
length of bytes read
Throws:
java.io.IOException - if an I/O related error occurs

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read data from telnet stream with escaping control characters.

Overrides:
read in class java.io.InputStream
Parameters:
b - buffer to read data from
off - offset in buffer to start reading from
len - length of data to read from offset
Returns:
total number of bytes read
Throws:
java.io.IOException - if an I/O related error occurs

markSupported

public boolean markSupported()
Checks if mark is supported in this TelnetInputStream

Overrides:
markSupported in class java.io.InputStream
Returns:
true if mark supported, false otherwise

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards n bytes of data from this input stream.

Overrides:
skip in class java.io.InputStream
Parameters:
n - the number of bytes to skip
Returns:
the actual number of bytes skipped
Throws:
java.io.IOException - if an I/O error occurs
See Also:
InputStream.skip(long)

mark

public void mark(int readlimit)
Marks the current position in this input stream.

Overrides:
mark in class java.io.InputStream
Parameters:
readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
See Also:
InputStream.mark(int)

available

public int available()
              throws java.io.IOException
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.

Overrides:
available in class java.io.InputStream
Returns:
the number of bytes that can be read from this input stream without blocking.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
InputStream.available()

flush

public void flush()
           throws java.io.IOException
Reads until the amount of data available is greater than 0 bytes

Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Repositions this stream to the position at the time the mark method was last called on this input stream.

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException - if an I/O related error occurs
See Also:
InputStream.reset()

readLine

public java.lang.String readLine(java.lang.String[] lbr)
                          throws java.io.IOException
Reads from the stream. This method will read from the stream until one of the supplied strings occured.

Parameters:
lbr - Line break sequences the method is expected to recognise
Returns:
a line from the underlying InputStream
Throws:
java.io.IOException - if an I/O related error occurs

readBlock

public java.lang.String readBlock(java.lang.String[] lbr)
                           throws java.io.IOException
Reads from the stream. This method will read from the stream until one of the supplied strings occured or no more data is available in the stream.

Parameters:
lbr - Array of strings to match against
Returns:
reads data from stream until one of the supplied strings is found
Throws:
java.io.IOException - if an I/O error occurs

SSH Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved