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

## com.mindprod.hunkio
Class PrintWriterPlus

    java.lang.Object
      java.io.Writer
          java.io.PrintWriter
              com.mindprod.hunkio.PrintWriterPlus

All Implemented Interfaces:
  java.io.Closeable, java.io.Flushable, java.lang.Appendable

Direct Known Subclasses:
  PrintWriterPortable

    public class PrintWriterPlus

extends java.io.PrintWriter

Extension of PrintWriter to deal proper[y with embedded \n character.

Prints lines with a configurable line separator character, even when it is embedded in the Strings to be printed, so long as you print with emit and emitln, rather than print and println. Use PrintWriter Portable if you want it to work even with text printed with print or println.

Since:
  2003-06-01
Version:
  1.3 2009-05-03 - create PrintWriterPlus vs PrintWriterPortable
Author:
  Roedy Green, Canadian Mind Products
See Also:
  "com.mindprod.hunkio.PrintWriterPortable", "com.mindprod.common11.Localise.localise(String)"

Field Summary
`protected java.lang.String` | `lineSeparator` lineSeparator using now.

Fields inherited from class java.io.PrintWriter
`out`

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

Constructor Summary
`PrintWriterPlus(java.io.OutputStream out)` Constructor just like PrintWriter.
`PrintWriterPlus(java.io.OutputStream out, boolean autoFlush)` Constructor just like PrintWriter.
`PrintWriterPlus(java.io.Writer out)` Constructor just like PrintWriter.
`PrintWriterPlus(java.io.Writer out, boolean autoFlush)` Constructor just like PrintWriter.

Method Summary
`void` | `emit(char c)` like PrintWriter.print, but emits platform dependent line separator if c is a \n Print a character.
`void` | `emit(java.lang.String s)` like PrintWriter.print, but converts embedded \n to platform-specific line terminators Print a string.
`void` | `emitln(char c)` Like PrintWriter.println, but emits two line separators if c is a \n.
`void` | `emitln(java.lang.String s)` like PrintWriter.println, but converts embedded \n to platform-specific line terminators Print a String and then terminate the line.
`static void` | `main(java.lang.String[] args)` Debugging test harness for PrintWriterPlus
`void` | `setLineSeparator(java.lang.String lineSeparator)` Use a line separator other than the system default.

Methods inherited from class java.io.PrintWriter
`append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write`

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

Field Detail

### lineSeparator

    protected java.lang.String lineSeparator

  lineSeparator using now.

Constructor Detail

### PrintWriterPlus

    public PrintWriterPlus(java.io.OutputStream out)

  Constructor just like PrintWriter. Create a new PrintWriterPlus, without automatic line flushing, from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.

  Parameters:
    `out` - An output stream
  See Also:
    `OutputStreamWriter.OutputStreamWriter(java.io.OutputStream)`

### PrintWriterPlus

    public PrintWriterPlus(java.io.Writer out)

  Constructor just like PrintWriter. Create a new PrintWriterPlus, without automatic line flushing.

  Parameters:
    `out` - A character-output stream

### PrintWriterPlus

    public PrintWriterPlus(java.io.OutputStream out,
                           boolean autoFlush)

  Constructor just like PrintWriter. Create a new PrintWriterPlus from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.

  Parameters:
    `out` - An output stream
    `autoFlush` - A boolean; if true, the println() methods will flush the output buffer
  See Also:
    `OutputStreamWriter.OutputStreamWriter(java.io.OutputStream)`

### PrintWriterPlus

    public PrintWriterPlus(java.io.Writer out,
                           boolean autoFlush)

  Constructor just like PrintWriter. Create a new PrintWriterPlus.

  Parameters:
    `out` - A character-output stream
    `autoFlush` - A boolean; if true, the println() methods will flush the output buffer

Method Detail

### emit

    public void emit(java.lang.String s)

  like PrintWriter.print, but converts embedded \n to platform-specific line terminators Print a string. Don't use emit on Strings that already contain crlf line endings. You will then get crcrlf as the result. Arrgh.

  Parameters:
    `s` - The `String` to be printed

### emit

    public void emit(char c)

  like PrintWriter.print, but emits platform dependent line separator if c is a \n Print a character.

  Parameters:
    `c` - The `char` to be printed

### emitln

    public void emitln(char c)

  Like PrintWriter.println, but emits two line separators if c is a \n. Print a character and then terminate the line.

  Parameters:
    `c` - the `char` value to be printed

### emitln

    public void emitln(java.lang.String s)

  like PrintWriter.println, but converts embedded \n to platform-specific line terminators Print a String and then terminate the line.

  Parameters:
    `s` - the `String` value to be printed

### setLineSeparator

    public void setLineSeparator(java.lang.String lineSeparator)

  Use a line separator other than the system default.

  Parameters:
    `lineSeparator` - Sequence to separate lines. usually Windows: "\r\n" Unix: "\n" or Mac: "\r". But could be anything.

### main

    public static void main(java.lang.String[] args)

  Debugging test harness for PrintWriterPlus

  Parameters:
    `args` - not used

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