Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.net.io
Class DotTerminatedMessageWriter

    java.lang.Object
      |
      +--java.io.Writer
            |
            +--org.apache.commons.net.io.DotTerminatedMessageWriter

public final class DotTerminatedMessageWriter
extends java.io.Writer

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 begining 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.

Author:
  Daniel F. Savarese

Field Summary

Fields inherited from class java.io.Writer
`lock`

Constructor Summary
`DotTerminatedMessageWriter(java.io.Writer output)` Creates a DotTerminatedMessageWriter that wraps an existing Writer output destination.

Method Summary
`void` | `close()` Flushes the underlying output, writing all buffered output, but doesn't actually close the underlying stream.
`void` | `flush()` Flushes the underlying output, writing all buffered output.
`void` | `write(char[] buffer)` Writes a character array to the output.
`void` | `write(char[] buffer, int offset, int length)` Writes a number of characters from a character array to the output starting from a given offset.
`void` | `write(int ch)` Writes a character to the output.
`void` | `write(java.lang.String string)` Writes a String to the output.
`void` | `write(java.lang.String string, int offset, int length)` Writes part of a String to the output starting from a given offset.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DotTerminatedMessageWriter

    public DotTerminatedMessageWriter(java.io.Writer output)

  Creates a DotTerminatedMessageWriter that wraps an existing Writer output destination.

Parameters:
  `output` - The Writer output destination to write the message.

Method Detail

### write

    public void write(int ch)
               throws java.io.IOException

  Writes 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:
    `write` in class `java.io.Writer`
  Parameters:
    `ch` - The character to write.
  Throws:
    `java.io.IOException` - If an error occurs while writing to the underlying output.

### write

    public void write(char[] buffer,
                      int offset,
                      int length)
               throws java.io.IOException

  Writes a number of characters from a character array to the output starting from a given offset.

  Specified by:
    `write` in class `java.io.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:
    `java.io.IOException` - If an error occurs while writing to the underlying output.

### write

    public void write(char[] buffer)
               throws java.io.IOException

  Writes a character array to the output.

  Overrides:
    `write` in class `java.io.Writer`
  Parameters:
    `buffer` - The character array to write.
  Throws:
    `java.io.IOException` - If an error occurs while writing to the underlying output.

### write

    public void write(java.lang.String string)
               throws java.io.IOException

  Writes a String to the output.

  Overrides:
    `write` in class `java.io.Writer`
  Parameters:
    `string` - The String to write.
  Throws:
    `java.io.IOException` - If an error occurs while writing to the underlying output.

### write

    public void write(java.lang.String string,
                      int offset,
                      int length)
               throws java.io.IOException

  Writes part of a String to the output starting from a given offset.

  Overrides:
    `write` in class `java.io.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:
    `java.io.IOException` - If an error occurs while writing to the underlying output.

### flush

    public void flush()
               throws java.io.IOException

  Flushes the underlying output, writing all buffered output.

  Specified by:
    `flush` in class `java.io.Writer`
  Throws:
    `java.io.IOException` - If an error occurs while writing to the underlying output.

### close

    public void close()
               throws java.io.IOException

  Flushes 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:
    `close` in class `java.io.Writer`
  Throws:
    `java.io.IOException` - If an error occurs while writing to the underlying output or closing the Writer.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1997-2003 Apache Software Foundation. All Rights Reserved.