Package org.apache.commons.net.io
Class DotTerminatedMessageWriter
java.lang.Object
java.io.Writer
org.apache.commons.net.io.DotTerminatedMessageWriter
- All Implemented Interfaces:
- Closeable,- Flushable,- Appendable,- AutoCloseable
DotTerminatedMessageWriter is a class used to write messages to a server that are terminated by a single dot followed by a <CR><LF> sequence and
 with double dots appearing at the beginning of lines which do not signal end of message yet start with a dot. Various Internet protocols such as
 NNTP and POP3 produce messages of this type.
 
This class handles the doubling of line-starting periods, converts single linefeeds to NETASCII newlines, and on closing will send the final message terminator dot and NETASCII newline sequence.
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionDotTerminatedMessageWriter(Writer output) Creates a DotTerminatedMessageWriter that wraps an existing Writer output destination.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Flushes the underlying output, writing all buffered output, but doesn't actually close the underlying stream.voidflush()Flushes the underlying output, writing all buffered output.voidwrite(char[] buffer) Writes a character array to the output.voidwrite(char[] buffer, int offset, int length) Writes a number of characters from a character array to the output starting from a given offset.voidwrite(int ch) Writes a character to the output.voidWrites a String to the output.voidWrites part of a String to the output starting from a given offset.
- 
Constructor Details- 
DotTerminatedMessageWriterCreates a DotTerminatedMessageWriter that wraps an existing Writer output destination.- Parameters:
- output- The Writer output destination to write the message.
 
 
- 
- 
Method Details- 
closeFlushes the underlying output, writing all buffered output, but doesn't actually close the underlying stream. The underlying stream may still be used for communicating with the server and therefore is not closed.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- Writer
- Throws:
- IOException- If an error occurs while writing to the underlying output or closing the Writer.
 
- 
flushFlushes the underlying output, writing all buffered output.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin class- Writer
- Throws:
- IOException- If an error occurs while writing to the underlying output.
 
- 
writeWrites a character array to the output.- Overrides:
- writein class- Writer
- Parameters:
- buffer- The character array to write.
- Throws:
- IOException- If an error occurs while writing to the underlying output.
 
- 
writeWrites a number of characters from a character array to the output starting from a given offset.- Specified by:
- writein class- Writer
- Parameters:
- buffer- The character array to write.
- offset- The offset into the array at which to start copying data.
- length- The number of characters to write.
- Throws:
- IOException- If an error occurs while writing to the underlying output.
 
- 
writeWrites a character to the output. Note that a call to this method may result in multiple writes to the underling Writer in order to convert naked linefeeds to NETASCII line separators and to double line-leading periods. This is transparent to the programmer and is only mentioned for completeness.- Overrides:
- writein class- Writer
- Parameters:
- ch- The character to write.
- Throws:
- IOException- If an error occurs while writing to the underlying output.
 
- 
writeWrites a String to the output.- Overrides:
- writein class- Writer
- Parameters:
- string- The String to write.
- Throws:
- IOException- If an error occurs while writing to the underlying output.
 
- 
writeWrites part of a String to the output starting from a given offset.- Overrides:
- writein class- Writer
- Parameters:
- string- The String to write.
- offset- The offset into the String at which to start copying data.
- length- The number of characters to write.
- Throws:
- IOException- If an error occurs while writing to the underlying output.
 
 
-