|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread org.jpop.io.ThreadedFileWriter
This class takes a BufferedReader and a File object, then opens the file for writing and reads whatever is interfacethe buffered reader until this is empty whilst writing to the file the contents. At the end it closes both the file and the reader and stops. To use this class, you must define methods for all the events:
ThreadedFileWriter tfw = new ThreadedFileWriter(filename, reader){ public void exceptionGenerated(Exception e){ // stuff to do when an exception is fired } public void fileChanged(){ //stuff to do when file changes } public void fileClosed(){ // stuff to do when file is closed } public void fileOpened(){ // stuff to do when file is opened } }.start();
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
ThreadedFileWriter(java.io.File f)
Constructor for the ThreadedFileWriter object |
|
ThreadedFileWriter(java.io.File f,
LogWindow lw)
Constructor for the ThreadedFileWriter object |
|
ThreadedFileWriter(java.io.File f,
java.lang.String name)
Constructor for the ThreadedFileWriter object |
Method Summary | |
void |
append(java.lang.String s)
|
void |
close()
close the thread |
abstract void |
exceptionGenerated(java.lang.Exception e)
This is fired when an exception gets generated interfacethe main loop |
abstract void |
fileChanged()
This is fired when the file is changed |
abstract void |
fileClosed()
This is fired when the file gets closed |
abstract void |
fileOpened()
This is fired when the file is opened |
java.io.BufferedReader |
getReader()
Gets the reader value of the ThreadedFileWriter object |
boolean |
isCanClose()
Gets the can close value of the ThreadedFileWriter object |
void |
run()
Main processing method for ThreadedFileWriter |
void |
setCanClose(boolean b)
Sets the can close value of the ThreadedFileWriter object |
void |
setReader(java.io.BufferedReader br)
Sets the reader value of the ThreadedFileWriter object |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ThreadedFileWriter(java.io.File f) throws java.io.FileNotFoundException, java.io.IOException
f
- The file this object is to write to
java.io.FileNotFoundException
- When the file can't be found by java
java.io.IOException
- When the file can't be written topublic ThreadedFileWriter(java.io.File f, LogWindow lw) throws java.io.FileNotFoundException, java.io.IOException
f
- The file this object is to write tolw
-
java.io.FileNotFoundException
- When the file can't be found by java
java.io.IOException
- When the file can't be written topublic ThreadedFileWriter(java.io.File f, java.lang.String name) throws java.io.FileNotFoundException, java.io.IOException
f
- The file this object is to write toname
-
java.io.FileNotFoundException
- When the file can't be found by java
java.io.IOException
- When the file can't be written toMethod Detail |
public final void run()
public void setCanClose(boolean b)
b
- The new canClose valuepublic void setReader(java.io.BufferedReader br)
br
- The new reader valuepublic java.io.BufferedReader getReader()
public boolean isCanClose()
public void append(java.lang.String s)
s
- public void close()
public abstract void exceptionGenerated(java.lang.Exception e)
e
- The exceptionpublic abstract void fileChanged()
public abstract void fileClosed()
public abstract void fileOpened()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |