Build 1.0_r1(from source)

java.io
Class LineNumberInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.LineNumberInputStream
All Implemented Interfaces:
Closeable

Deprecated. Use LineNumberReader

@Deprecated
public class LineNumberInputStream
extends FilterInputStream

LineNumberInputStream is a filter class which counts the number of line terminators from the data read from the target InputStream. A line delimiter sequence is determined by '\r', '\n', or '\r\n'. When using read, the sequence is always translated into '\n'.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
LineNumberInputStream(InputStream in)
          Deprecated. Constructs a new LineNumberInputStream on the InputStream in.
 
Method Summary
 int available()
          Deprecated. Returns a int representing the number of bytes that are available before this LineNumberInputStream will block.
 int getLineNumber()
          Deprecated. Returns a int representing the current line number for this LineNumberInputStream.
 void mark(int readlimit)
          Deprecated. Set a Mark position in this LineNumberInputStream.
 int read()
          Deprecated. Reads a single byte from this LineNumberInputStream and returns the result as an int.
 int read(byte[] buffer, int offset, int length)
          Deprecated. Reads at most length bytes from this LineNumberInputStream and stores them in byte array buffer starting at offset.
 void reset()
          Deprecated. Reset this LineNumberInputStream to the last marked location.
 void setLineNumber(int lineNumber)
          Deprecated. Sets the lineNumber of this LineNumberInputStream to the specified lineNumber.
 long skip(long count)
          Deprecated. Skips count number of bytes in this InputStream.
 
Methods inherited from class java.io.FilterInputStream
close, markSupported, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineNumberInputStream

public LineNumberInputStream(InputStream in)
Deprecated. 
Constructs a new LineNumberInputStream on the InputStream in. All reads are now filtered through this stream and line numbers will be counted for all data read from this Stream.

Parameters:
in - The non-null InputStream to count line numbers.
Method Detail

available

public int available()
              throws IOException
Deprecated. 
Returns a int representing the number of bytes that are available before this LineNumberInputStream will block. This method returns the number of bytes available in the target stream. Since the target input stream may just be a sequence of \r\n characters and this filter only returns \n then available can only guarantee target.available()/2 characters.

Overrides:
available in class FilterInputStream
Returns:
int the number of bytes available before blocking.
Throws:
IOException - If an error occurs in this stream.

getLineNumber

public int getLineNumber()
Deprecated. 
Returns a int representing the current line number for this LineNumberInputStream.

Returns:
int the current line number.

mark

public void mark(int readlimit)
Deprecated. 
Set a Mark position in this LineNumberInputStream. The parameter readLimit indicates how many bytes can be read before a mark is invalidated. Sending reset() will reposition the Stream back to the marked position provided readLimit has not been surpassed. The lineNumber count will also be reset to the last marked lineNumber count.

This implementation sets a mark in the target stream.

Overrides:
mark in class FilterInputStream
Parameters:
readlimit - The number of bytes to be able to read before invalidating the mark.

read

public int read()
         throws IOException
Deprecated. 
Reads a single byte from this LineNumberInputStream and returns the result as an int. The low-order byte is returned or -1 of the end of stream was encountered. This implementation returns a byte from the target stream. The line number count is incremented if a line terminator is encountered. A line delimiter sequence is determined by '\r', '\n', or '\r\n'. In this method, the sequence is always translated into '\n'.

Overrides:
read in class FilterInputStream
Returns:
int The byte read or -1 if end of stream.
Throws:
IOException - If the stream is already closed or another IOException occurs.

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException
Deprecated. 
Reads at most length bytes from this LineNumberInputStream and stores them in byte array buffer starting at offset. Answer the number of bytes actually read or -1 if no bytes were read and end of stream was encountered. This implementation reads bytes from the target stream. The line number count is incremented if a line terminator is encountered. A line delimiter sequence is determined by '\r', '\n', or '\r\n'. In this method, the sequence is always translated into '\n'.

Overrides:
read in class FilterInputStream
Parameters:
buffer - the non-null byte array in which to store the read bytes.
offset - the offset in buffer to store the read bytes.
length - the maximum number of bytes to store in buffer.
Returns:
The number of bytes actually read or -1 if end of stream.
Throws:
IOException - If the stream is already closed or another IOException occurs.
NullPointerException - If buffer is null.
IllegalArgumentException - If offset or count are out of bounds.

reset

public void reset()
           throws IOException
Deprecated. 
Reset this LineNumberInputStream to the last marked location. If the readlimit has been passed or no mark has been set, throw IOException. This implementation resets the target stream. It also resets the line count to what is was when this Stream was marked.

Overrides:
reset in class FilterInputStream
Throws:
IOException - If the stream is already closed or another IOException occurs.

setLineNumber

public void setLineNumber(int lineNumber)
Deprecated. 
Sets the lineNumber of this LineNumberInputStream to the specified lineNumber. Note that this may have side effects on the line number associated with the last marked position.

Parameters:
lineNumber - the new lineNumber value.

skip

public long skip(long count)
          throws IOException
Deprecated. 
Skips count number of bytes in this InputStream. Subsequent read()'s will not return these bytes unless reset() is used. This implementation skips count number of bytes in the target stream and increments the lineNumber count as bytes are skipped.

Overrides:
skip in class FilterInputStream
Parameters:
count - the number of bytes to skip.
Returns:
the number of bytes actually skipped.
Throws:
IOException - If the stream is already closed or another IOException occurs.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature