calypso.util
Class LineBufferingInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--calypso.util.LineBufferingInputStream

public class LineBufferingInputStream
extends java.io.FilterInputStream


Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
LineBufferingInputStream(java.io.InputStream s)
           
 
Method Summary
 void close()
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] buf)
           
 int read(byte[] buf, int start, int length)
          Reads bytes into a portion of an array.
 void setInputEOL(ByteBuf buf)
          Sets the EOL characters to look for in the incoming stream.
 void setOutputEOL(ByteBuf buf)
          End of line characters & or any combination will be replaced by this string if it is present.
 long skip(long n)
           
 
Methods inherited from class java.io.FilterInputStream
available, mark, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineBufferingInputStream

public LineBufferingInputStream(java.io.InputStream s)
Method Detail

read

public int read(byte[] buf,
                int start,
                int length)
         throws java.io.IOException
Reads bytes into a portion of an array. This method will block until some input is available.

The returned data will not be more than one line long: that is, there will be at most one linebreak (CR, LF, or CRLF) and if it is present, it will be at the end.

If the next line available to be read is smaller than `length', then the first `length' bytes of that line will be returned, and the remainder of the bytes on that line will be available for subsequent reads.

Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Overrides:
read in class java.io.FilterInputStream

read

public int read(byte[] buf)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream

skip

public long skip(long n)
Overrides:
skip in class java.io.FilterInputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.FilterInputStream

close

public void close()
           throws java.io.IOException
Overrides:
close in class java.io.FilterInputStream

setInputEOL

public void setInputEOL(ByteBuf buf)
Sets the EOL characters to look for in the incoming stream. Setting this to be null will cause it to look for any of , , or . Note that null (the default) could cause up to one extra to be held in the buffer (in the case where the last byte read from the underlying stream was , and no following byte (or EOF) has yet been read.)

setOutputEOL

public void setOutputEOL(ByteBuf buf)
End of line characters & or any combination will be replaced by this string if it is present. Setting this to a zero length string will cause them to be stripped. Setting this to null will cause the EOL characters to be passed through unchanged (the default).
Parameters:
buf - ByteBuf representing EOL replacement string