persistence.antlr
Class PreservingFileWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.OutputStreamWriter
          extended by java.io.FileWriter
              extended by persistence.antlr.PreservingFileWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class PreservingFileWriter
extends java.io.FileWriter

PreservingFileWriter only overwrites target if the new file is different. Mainly added in order to prevent big and unnecessary recompiles in C++ projects. I/O is buffered.


Field Summary
protected  java.io.File target_file
           
protected  java.io.File tmp_file
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
PreservingFileWriter(java.lang.String file)
           
 
Method Summary
 void close()
          Close the file and see if the actual target is different if so the target file is overwritten by the copy.
 
Methods inherited from class java.io.OutputStreamWriter
flush, getEncoding, write, write, write
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

target_file

protected java.io.File target_file

tmp_file

protected java.io.File tmp_file
Constructor Detail

PreservingFileWriter

public PreservingFileWriter(java.lang.String file)
                     throws java.io.IOException
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Close the file and see if the actual target is different if so the target file is overwritten by the copy. If not we do nothing

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStreamWriter
Throws:
java.io.IOException