gnu.inet.ftp
Class AsciiInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--gnu.inet.ftp.AsciiInputStream
- public class AsciiInputStream
- extends java.io.FilterInputStream
The AsciiInputStream class acts as a filter to convert incoming
ASCII FTP streams to the system's local ASCII format by filtering and
converting line termination strings. Note that the class as currently
written will only handle \r\n or single character line
termination strings; a more technically correct implementation would be
preferable.
| Fields inherited from class java.io.FilterInputStream |
in |
|
Constructor Summary |
AsciiInputStream(java.io.InputStream in)
Creates an AsciiInputStream by passing in to its superclass'
constructor and determining the system-specific line termination string. |
|
Method Summary |
int |
available()
Returns the number of bytes that can be read from this input stream
without blocking. |
void |
mark(int readlimit)
Marks the current position in this input stream. |
int |
read()
Reads the next byte of data. |
int |
read(byte[] b)
Reads up to byte.length bytes of data from this input stream
into an array of bytes. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from this input stream into an
array of bytes. |
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 the input stream. |
| Methods inherited from class java.io.FilterInputStream |
close, markSupported |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
active
protected boolean active
eol
protected int eol
buffer
protected int buffer
markBuffer
protected int markBuffer
AsciiInputStream
public AsciiInputStream(java.io.InputStream in)
throws java.lang.Exception
- Creates an AsciiInputStream by passing
in to its superclass'
constructor and determining the system-specific line termination string.
- Parameters:
in - the underlying input stream.- Throws:
java.lang.Exception - if system line separator is longer than 1 char and is
not \r\n
read
public int read()
throws java.io.IOException
- Reads the next byte of data.
- Overrides:
read in class java.io.FilterInputStream
- Returns:
- the next byte of data, or -1 for EOF
- Throws:
java.io.IOException - if an I/O error occurs.
read
public int read(byte[] b)
throws java.io.IOException
- Reads up to
byte.length bytes of data from this input stream
into an array of bytes.
- Overrides:
read in class java.io.FilterInputStream
- Parameters:
b - the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer, or -1 for EOF.
- Throws:
java.io.IOException - if an I/O error occurs.
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Reads up to
len bytes of data from this input stream into an
array of bytes.
- Overrides:
read in class java.io.FilterInputStream
- Parameters:
b - the buffer into which the data is read.off - the start offset of the data.len - the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or -1 for EOF.
- Throws:
java.io.IOException - if an I/O error occurs.
skip
public long skip(long n)
throws java.io.IOException
- Skips over and discards n bytes of data from the input stream.
- Overrides:
skip in class java.io.FilterInputStream
- Parameters:
n - the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped.
- Throws:
java.io.IOException - if an I/O error occurs.
available
public int available()
throws java.io.IOException
- Returns the number of bytes that can be read from this input stream
without blocking.
- Overrides:
available in class java.io.FilterInputStream
- Returns:
- the number of bytes that can be read from the input stream
without blocking.
- Throws:
java.io.IOException - if an I/O error occurs.
mark
public void mark(int readlimit)
- Marks the current position in this input stream.
- Overrides:
mark in class java.io.FilterInputStream
- Parameters:
readlimit - the maximum limit of bytes that can be read before the
mark position becomes invalid.
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.FilterInputStream
- Throws:
java.io.IOException - if the stream has not been or cannot be marked or
if the mark has been invalidated.