facets.util
Class TextLines

java.lang.Object
  extended by facets.util.Tracer
      extended by facets.util.TextLines

public final class TextLines
extends Tracer

Reads from and where allowed writes lines to a wrapped text file reference.

Can be constructed either from a File or URL; read-only in the latter case.


Field Summary
 long chars
           
static java.lang.String DEFAULT_ENCODING
           
static java.lang.String encoding
           [?Cp1252 Eclipse standard] US-ASCII Seven-bit ASCII, a.k.a.
static java.lang.String EXT_CLEAR
           
static java.lang.String EXT_ZIP
           
 long lines
           
 java.lang.Object reference
           
static boolean trace
           
 
Constructor Summary
TextLines(java.io.File file)
          Wrap a file reference.
TextLines(java.io.InputStream in)
          Wrap an input stream.
TextLines(java.io.OutputStream out)
          Wrap an output stream.
TextLines(java.net.URL url)
          Wrap a URL reference.
 
Method Summary
 void closeLineWriter()
           
 void copyFile(java.lang.String outName)
           
static void createIfRequired(java.io.File file, java.lang.String content)
           
 java.lang.String getFileName()
           
 boolean hasNextLine()
           
static TextLines newBuffer()
           
static TextLines newBuffer(java.lang.String[] lines)
           
 java.io.InputStream newInputStream()
           
 java.io.OutputStream newOutputStream()
           
 java.io.BufferedReader newReader()
           
 java.lang.String nextLine()
           
 java.lang.String[] readLines()
           
 java.lang.String readLinesString()
          Attempts to read text lines from the reference or buffer wrapped.
static void setDefaultEncoding(boolean systemAccess)
           
static void setEncoding(java.lang.String encoding)
           
 java.lang.String toString()
           
protected  void traceOutput(java.lang.String msg)
          Outputs complete trace messages to console or elsewhere.
 void writeAllLines(java.lang.String[] lines)
          Attempts to write text lines to the reference wrapped.
 void writeNextLine(java.lang.String line)
           
 
Methods inherited from class facets.util.Tracer
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutputWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final java.lang.String DEFAULT_ENCODING
See Also:
Constant Field Values

EXT_ZIP

public static final java.lang.String EXT_ZIP
See Also:
Constant Field Values

EXT_CLEAR

public static final java.lang.String EXT_CLEAR
See Also:
Constant Field Values

lines

public long lines

chars

public long chars

encoding

public static java.lang.String encoding
[?Cp1252 Eclipse standard]
US-ASCII Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set 
ISO-8859-1   ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 
UTF-8 Eight-bit UCS Transformation Format 
UTF-16BE Sixteen-bit UCS Transformation Format, big-endian byte order 
UTF-16LE Sixteen-bit UCS Transformation Format, little-endian byte order 
UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark


trace

public static boolean trace

reference

public final java.lang.Object reference
Constructor Detail

TextLines

public TextLines(java.io.File file)
Wrap a file reference.

Parameters:
file - must be non-null

TextLines

public TextLines(java.net.URL url)
Wrap a URL reference.

Parameters:
url - must be non-null

TextLines

public TextLines(java.io.OutputStream out)
Wrap an output stream.

Parameters:
out - must be non-null

TextLines

public TextLines(java.io.InputStream in)
Wrap an input stream.

Parameters:
in - must be non-null
Method Detail

getFileName

public java.lang.String getFileName()

traceOutput

protected void traceOutput(java.lang.String msg)
Description copied from class: Tracer
Outputs complete trace messages to console or elsewhere.

Default prepends helpful classname to message.

Overrides:
traceOutput in class Tracer
Parameters:
msg - passed from one of the public methods

writeAllLines

public void writeAllLines(java.lang.String[] lines)
                   throws java.io.IOException
Attempts to write text lines to the reference wrapped.

Throws:
java.io.IOException

writeNextLine

public void writeNextLine(java.lang.String line)
                   throws java.io.IOException
Throws:
java.io.IOException

closeLineWriter

public void closeLineWriter()

newOutputStream

public java.io.OutputStream newOutputStream()
                                     throws java.io.IOException
Throws:
java.io.IOException

newInputStream

public java.io.InputStream newInputStream()
                                   throws java.io.IOException
Throws:
java.io.IOException

hasNextLine

public boolean hasNextLine()
                    throws java.io.IOException
Throws:
java.io.IOException

newReader

public java.io.BufferedReader newReader()
                                 throws java.io.IOException
Throws:
java.io.IOException

nextLine

public java.lang.String nextLine()
                          throws java.io.IOException
Throws:
java.io.IOException

readLines

public java.lang.String[] readLines()
                             throws java.io.IOException
Throws:
java.io.IOException

readLinesString

public java.lang.String readLinesString()
                                 throws java.io.IOException
Attempts to read text lines from the reference or buffer wrapped.

Throws:
java.io.IOException

newBuffer

public static TextLines newBuffer()

newBuffer

public static TextLines newBuffer(java.lang.String[] lines)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

copyFile

public void copyFile(java.lang.String outName)
              throws java.io.IOException
Throws:
java.io.IOException

setDefaultEncoding

public static void setDefaultEncoding(boolean systemAccess)

setEncoding

public static void setEncoding(java.lang.String encoding)

createIfRequired

public static void createIfRequired(java.io.File file,
                                    java.lang.String content)
                             throws java.io.IOException
Throws:
java.io.IOException