Package org.apache.commons.net.telnet
Class TelnetOutputStream
java.lang.Object
java.io.OutputStream
org.apache.commons.net.telnet.TelnetOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final TelnetClient
private final boolean
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the stream.void
flush()
Flushes the stream.void
write
(byte[] buffer) Writes a byte array to the stream.void
write
(byte[] buffer, int offset, int length) Writes a number of bytes from a byte array to the stream starting from a given offset.void
write
(int ch) Writes a byte to the stream.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
client
-
convertCRtoCRLF
private final boolean convertCRtoCRLF- See Also:
-
lastWasCR
private boolean lastWasCR
-
-
Constructor Details
-
TelnetOutputStream
TelnetOutputStream(TelnetClient client)
-
-
Method Details
-
close
Closes the stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
flush
Flushes the stream.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
write
Writes a byte array to the stream.- Overrides:
write
in classOutputStream
- Parameters:
buffer
- The byte array to write.- Throws:
IOException
- If an error occurs while writing to the underlying stream.
-
write
Writes a number of bytes from a byte array to the stream starting from a given offset.- Overrides:
write
in classOutputStream
- 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.
-
write
Writes a byte to the stream.- Specified by:
write
in classOutputStream
- Parameters:
ch
- The byte to write.- Throws:
IOException
- If an error occurs while writing to the underlying stream.
-