Package org.apache.commons.net.telnet
Class TelnetOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.commons.net.telnet.TelnetOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
final class TelnetOutputStream extends java.io.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 Summary
Fields Modifier and Type Field Description private TelnetClient
client
private boolean
convertCRtoCRLF
private boolean
lastWasCR
-
Constructor Summary
Constructors Constructor Description TelnetOutputStream(TelnetClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.
-
-
-
Field Detail
-
client
private final TelnetClient client
-
convertCRtoCRLF
private final boolean convertCRtoCRLF
- See Also:
- Constant Field Values
-
lastWasCR
private boolean lastWasCR
-
-
Constructor Detail
-
TelnetOutputStream
TelnetOutputStream(TelnetClient client)
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Closes the stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
Flushes the stream.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] buffer) throws java.io.IOException
Writes a byte array to the stream.- Overrides:
write
in classjava.io.OutputStream
- Parameters:
buffer
- The byte array to write.- Throws:
java.io.IOException
- If an error occurs while writing to the underlying stream.
-
write
public void write(byte[] buffer, int offset, int length) throws java.io.IOException
Writes a number of bytes from a byte array to the stream starting from a given offset.- Overrides:
write
in classjava.io.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:
java.io.IOException
- If an error occurs while writing to the underlying stream.
-
write
public void write(int ch) throws java.io.IOException
Writes a byte to the stream.- Specified by:
write
in classjava.io.OutputStream
- Parameters:
ch
- The byte to write.- Throws:
java.io.IOException
- If an error occurs while writing to the underlying stream.
-
-