to.tetramorph.util
クラス LoggerOutputStream

java.lang.Object
  上位を拡張 java.io.OutputStream
      上位を拡張 to.tetramorph.util.LoggerOutputStream
すべての実装されたインタフェース:
Closeable, Flushable

public class LoggerOutputStream
extends OutputStream

System.outやSystem.errの出力を、コンソールだけではなくファイルにも出力できる ようにするストリーム。 次のように使う。

 エラーと標準出力を別々にファイル出力したいとき。
 System.setOut(new PrintStream(new LoggerOutputStream( log_file,System.out)));
 System.setErr(new PrintStream(new LoggerOutputStream( err_file,System.out)));
 エラーと標準出力をまとめて一本のファイルに記録したいとき。
 PrintStream ps = new PrintStream(new LoggerOutputStream( log_file,System.out));
 System.setOut(ps);
 System.setErr(ps);
 
なおスレッドセーフではない。スレッドセーフであるべきだが、それを実装しようと するとこういうやり方ではそもそも無理がありすぎる。


コンストラクタの概要
LoggerOutputStream(File logFile, PrintStream ps)
           
 
メソッドの概要
 void close()
           
 void write(int b)
           
 
クラス java.io.OutputStream から継承されたメソッド
flush, write, write
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

LoggerOutputStream

public LoggerOutputStream(File logFile,
                          PrintStream ps)
                   throws IOException
例外:
IOException
メソッドの詳細

write

public void write(int b)
           throws IOException
定義:
クラス OutputStream 内の write
例外:
IOException

close

public void close()
定義:
インタフェース Closeable 内の close
オーバーライド:
クラス OutputStream 内の close