Class TelnetOutputStream

java.lang.Object
java.io.OutputStream
org.apache.commons.net.telnet.TelnetOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

final class TelnetOutputStream extends OutputStream
Wraps an output stream.

In binary mode, the only conversion is to double IAC.

In ASCII mode, if convertCRtoCRLF is true (currently always true), any CR is converted to CRLF. IACs are doubled. Also a bare LF is converted to CRLF and a bare CR is converted to CR\0

  • Field Details

    • client

      private final TelnetClient client
    • convertCRtoCRLF

      private final boolean convertCRtoCRLF
      See Also:
    • lastWasCR

      private boolean lastWasCR
  • Constructor Details

    • TelnetOutputStream

      TelnetOutputStream(TelnetClient client)
  • Method Details

    • write

      public void write(int ch) throws IOException
      Writes a byte to the stream.

      Specified by:
      write in class OutputStream
      Parameters:
      ch - The byte to write.
      Throws:
      IOException - If an error occurs while writing to the underlying stream.
    • write

      public void write(byte[] buffer) throws IOException
      Writes a byte array to the stream.

      Overrides:
      write in class OutputStream
      Parameters:
      buffer - The byte array to write.
      Throws:
      IOException - If an error occurs while writing to the underlying stream.
    • write

      public void write(byte[] buffer, int offset, int length) throws IOException
      Writes a number of bytes from a byte array to the stream starting from a given offset.

      Overrides:
      write in class OutputStream
      Parameters:
      buffer - The byte array to write.
      offset - The offset into the array at which to start copying data.
      length - The number of bytes to write.
      Throws:
      IOException - If an error occurs while writing to the underlying stream.
    • flush

      public void flush() throws IOException
      Flushes the stream.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Closes the stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException