Class PacketLineIn


  • public class PacketLineIn
    extends java.lang.Object
    Read Git style pkt-line formatting from an input stream.

    This class is not thread safe and may issue multiple reads to the underlying stream for each method call made.

    This class performs no buffering on its own. This makes it suitable to interleave reads performed by this class with reads performed directly against the underlying InputStream.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String END
      Magic return from readString() when a flush packet is found.
    • Constructor Summary

      Constructors 
      Constructor Description
      PacketLineIn​(java.io.InputStream i)
      Create a new packet line reader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String readString()
      Read a single UTF-8 encoded string packet from the input stream.
      java.lang.String readStringRaw()
      Read a single UTF-8 encoded string packet from the input stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • END

        public static final java.lang.String END
        Magic return from readString() when a flush packet is found.
    • Constructor Detail

      • PacketLineIn

        public PacketLineIn​(java.io.InputStream i)
        Create a new packet line reader.
        Parameters:
        i - the input stream to consume.
    • Method Detail

      • readString

        public java.lang.String readString()
                                    throws java.io.IOException
        Read a single UTF-8 encoded string packet from the input stream.

        If the string ends with an LF, it will be removed before returning the value to the caller. If this automatic trimming behavior is not desired, use readStringRaw() instead.

        Returns:
        the string. END if the string was the magic flush packet.
        Throws:
        java.io.IOException - the stream cannot be read.
      • readStringRaw

        public java.lang.String readStringRaw()
                                       throws java.io.IOException
        Read a single UTF-8 encoded string packet from the input stream.

        Unlike readString() a trailing LF will be retained.

        Returns:
        the string. END if the string was the magic flush packet.
        Throws:
        java.io.IOException - the stream cannot be read.