javoids
Class TextLoader

java.lang.Object
  extended by java.lang.Thread
      extended by javoids.TextLoader
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class TextLoader
extends java.lang.Thread
implements java.io.Serializable

A class to load text files robustly in a thread

Author:
mallette
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static int BUFFERMAXIMUM
          The maxmimum buffer size to use when storing loaded text files.
private static int BUFFERSIZE
          The buffer size to use when loading text files (amount read at once).
private  java.lang.StringBuffer fileData
          The buffer to use for loading files.
private  java.lang.String fileName
          The file name to use.
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TextLoader(java.lang.String _fileName)
          Constructor
 
Method Summary
 java.lang.String getText()
           
 void run()
          Run a separate thread to load the file.
 java.lang.String toString()
          Provide a String representation of this object.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object

See Also:
Constant Field Values

BUFFERSIZE

private static final int BUFFERSIZE
The buffer size to use when loading text files (amount read at once).

See Also:
Constant Field Values

BUFFERMAXIMUM

private static final int BUFFERMAXIMUM
The maxmimum buffer size to use when storing loaded text files.

See Also:
Constant Field Values

fileData

private java.lang.StringBuffer fileData
The buffer to use for loading files.


fileName

private java.lang.String fileName
The file name to use.

Constructor Detail

TextLoader

public TextLoader(java.lang.String _fileName)
Constructor

Parameters:
_fileName - the name of the file to load
Method Detail

run

public void run()
Run a separate thread to load the file.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getText

public java.lang.String getText()
Returns:
the text of the file just loaded

toString

public java.lang.String toString()
Provide a String representation of this object.

Overrides:
toString in class java.lang.Thread
Returns:
String A representation of the object for debugging.