com.mindprod.hunkio
Class PrintWriterPortable

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by com.mindprod.hunkio.PrintWriterPlus
              extended by com.mindprod.hunkio.PrintWriterPortable
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public final class PrintWriterPortable
extends PrintWriterPlus

Extension of PrintWriter/PrinterWriterPlus to deal properly with embedded \n character.

Prints lines with a configurable line separator character, even when it is embedded in the Strings to be printed, even those 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.PrintWriterPlus", "com.mindprod.common11.Localise.localise(String)"

Field Summary
 
Fields inherited from class com.mindprod.hunkio.PrintWriterPlus
lineSeparator
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
PrintWriterPortable(java.io.OutputStream out)
          Constructor just like PrintWriter.
PrintWriterPortable(java.io.OutputStream out, boolean autoFlush)
          Constructor just like PrintWriter.
PrintWriterPortable(java.io.Writer out)
          Constructor just like PrintWriter.
PrintWriterPortable(java.io.Writer out, boolean autoFlush)
          Constructor just like PrintWriter.
 
Method Summary
static void main(java.lang.String[] args)
          Debugging test harness for PrintWriterPlus
 void print(char c)
          like PrintWriter.print, but emits platform dependent line separator if c is a \n Print a character.
 void println(char c)
          Like PrintWriter.println, but emits two line separators if c is a \n.
 void println(java.lang.String s)
          like PrintWriter.println, but converts embedded \n to platform-specific line terminators Print a String and then terminate the line.
 
Methods inherited from class com.mindprod.hunkio.PrintWriterPlus
emit, emit, emitln, emitln, setLineSeparator
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, printf, printf, 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
 

Constructor Detail

PrintWriterPortable

public PrintWriterPortable(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)

PrintWriterPortable

public PrintWriterPortable(java.io.Writer out)
Constructor just like PrintWriter. Create a new PrintWriterPlus, without automatic line flushing.

Parameters:
out - A character-output stream

PrintWriterPortable

public PrintWriterPortable(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)

PrintWriterPortable

public PrintWriterPortable(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

print

public void print(char c)
like PrintWriter.print, but emits platform dependent line separator if c is a \n Print a character.

Overrides:
print in class java.io.PrintWriter
Parameters:
c - The char to be printed

println

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

Overrides:
println in class java.io.PrintWriter
Parameters:
c - the char value to be printed

println

public void println(java.lang.String s)
like PrintWriter.println, but converts embedded \n to platform-specific line terminators Print a String and then terminate the line.

Overrides:
println in class java.io.PrintWriter
Parameters:
s - the String value to be printed

main

public static void main(java.lang.String[] args)
Debugging test harness for PrintWriterPlus

Parameters:
args - not used