Class MirrorPrintStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
org.eclipse.epsilon.common.dt.console.MirrorPrintStream
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
MirrorPrintStream is a PrintStream that mirrors all print/write operations into a file.
Only the write(), check() and close() methods need overriding given that any of the print() and
println() methods must go through these.
- Since:
- 1.6
- Author:
- Horacio Hoyos Rodriguez
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe file name.protected PrintStreamThe file stream.Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a MirrorPrintStream with autoflush.MirrorPrintStream(OutputStream os, boolean flush) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn true if either stream has an error.protected voidClears the internal error state of this stream.voidclose()voidDisable the mirror operation.voidflush()voidmirrorToFile(String fileName) Enable mirroring to the given file.voidmirrorToFile(String fileName, boolean append) Enable mirroring to the given file.protected voidsetError()Sets the error state of the stream totrue.voidwrite(byte[] x, int o, int l) voidwrite(int x) Methods inherited from class java.io.PrintStream
append, append, append, charset, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, write, writeBytesMethods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
fileStream
The file stream. -
fileName
The file name.
-
-
Constructor Details
-
MirrorPrintStream
-
MirrorPrintStream
Instantiates a MirrorPrintStream with autoflush.- Parameters:
os- the os
-
-
Method Details
-
checkError
public boolean checkError()Return true if either stream has an error.- Overrides:
checkErrorin classPrintStream
-
write
public void write(int x) - Overrides:
writein classPrintStream
-
write
public void write(byte[] x, int o, int l) - Overrides:
writein classPrintStream
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classPrintStream
-
flush
public void flush()- Specified by:
flushin interfaceFlushable- Overrides:
flushin classPrintStream
-
mirrorToFile
Enable mirroring to the given file. If there is an error the MirrorPrintStream will be flagged as having an error. By default bytes will be written to the beginning of the file- Parameters:
fileName- The name of the file to direct output.- See Also:
-
mirrorToFile
Enable mirroring to the given file. If there is an error the MirrorPrintStream will be flagged as having an error.- Parameters:
fileName- The name of the file to direct output.append- if true, then bytes will be written to the end of the file rather than the beginning
-
disableMirror
public void disableMirror()Disable the mirror operation. -
setError
protected void setError()Sets the error state of the stream totrue.This method will cause subsequent invocations of
checkError()to return true untilclearError()is invoked.- Overrides:
setErrorin classPrintStream
-
clearError
protected void clearError()Clears the internal error state of this stream.This method will cause subsequent invocations of
checkError()to return false until another write operation fails and invokessetError().- Overrides:
clearErrorin classPrintStream
-