Package org.eclipse.jgit.transport
Class PacketLineOut
- java.lang.Object
-
- org.eclipse.jgit.transport.PacketLineOut
-
public class PacketLineOut extends java.lang.Object
Write Git style pkt-line formatting to an output stream.This class is not thread safe and may issue multiple writes to the underlying stream for each method call made.
This class performs no buffering on its own. This makes it suitable to interleave writes performed by this class with writes performed directly against the underlying OutputStream.
-
-
Constructor Summary
Constructors Constructor Description PacketLineOut(java.io.OutputStream outputStream)
Create a new packet line writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
end()
Write a packet end marker, sometimes referred to as a flush command.void
flush()
Flush the underlying OutputStream.void
setFlushOnEnd(boolean flushOnEnd)
Set the flush behavior duringend()
.void
writePacket(byte[] packet)
Write a binary packet to the stream.void
writeString(java.lang.String s)
Write a UTF-8 encoded string as a single length-delimited packet.
-
-
-
Method Detail
-
setFlushOnEnd
public void setFlushOnEnd(boolean flushOnEnd)
Set the flush behavior duringend()
.- Parameters:
flushOnEnd
- if true, a flush-pkt written duringend()
also flushes the underlying stream.
-
writeString
public void writeString(java.lang.String s) throws java.io.IOException
Write a UTF-8 encoded string as a single length-delimited packet.- Parameters:
s
- string to write.- Throws:
java.io.IOException
- the packet could not be written, the stream is corrupted as the packet may have been only partially written.
-
writePacket
public void writePacket(byte[] packet) throws java.io.IOException
Write a binary packet to the stream.- Parameters:
packet
- the packet to write; the length of the packet is equal to the size of the byte array.- Throws:
java.io.IOException
- the packet could not be written, the stream is corrupted as the packet may have been only partially written.
-
end
public void end() throws java.io.IOException
Write a packet end marker, sometimes referred to as a flush command.Technically this is a magical packet type which can be detected separately from an empty string or an empty packet.
Implicitly performs a flush on the underlying OutputStream to ensure the peer will receive all data written thus far.
- Throws:
java.io.IOException
- the end marker could not be written, the stream is corrupted as the end marker may have been only partially written.
-
flush
public void flush() throws java.io.IOException
Flush the underlying OutputStream.Performs a flush on the underlying OutputStream to ensure the peer will receive all data written thus far.
- Throws:
java.io.IOException
- the underlying stream failed to flush.
-
-