com.ibm.awb.misc
Class LogFileOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.ibm.awb.misc.LogFileOutputStream

public class LogFileOutputStream
extends java.io.OutputStream

Write a log to a file. If the file does not exist, it will create it. If a directory of the file does not exist, ir will create the directory too.

Author:
GakuYamamoto

Constructor Summary
LogFileOutputStream(java.lang.String filename, long maxFileSize)
          Create an instance of this class.
 
Method Summary
 void close()
          Close this.
 void write(byte[] b)
          Write data to the log file.
 void write(byte[] b, int off, int len)
          Write data to the log file.
 void write(int b)
          Write data to the log file.
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogFileOutputStream

public LogFileOutputStream(java.lang.String filename,
                           long maxFileSize)
                    throws java.io.IOException
Create an instance of this class. If the file does not exist, it will create the file. If a directory of the file does not exist, it will create the directory too.
Parameters:
filename - log file name
maxFileSize - maximum file size of the log. If the size of the log file exceeds this value, the log file will be renamed and a new log file will be created.
Throws:
java.io.IOException - if fail to create or access the file.
Method Detail

close

public void close()
           throws java.io.IOException
Close this.
Overrides:
close in class java.io.OutputStream

write

public void write(byte[] b)
           throws java.io.IOException
Write data to the log file. If the size of the file exceeds maximum size of the file, this stream will rename the file to filename + ".arc" and create a new log file. If the file whose name is "filename + ".arc"" already exists, the existing file will be renamed to "filename + ".arc" + date.getMinutes() + date.getHours() + date.getDate() + date.getMonth() + date.getYear()", where date is current date.
Overrides:
write in class java.io.OutputStream
Parameters:
b - data.
Throws:
java.io.IOException - if fail to write the data.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Write data to the log file. If the size of the file exceeds maximum size of the file, this stream will rename the file to filename + ".arc" and create a new log file. If the file whose name is "filename + ".arc"" already exists, the existing file will be renamed to "filename + ".arc" + date.getMinutes() + date.getHours() + date.getDate() + date.getMonth() + date.getYear()", where date is current date.
Overrides:
write in class java.io.OutputStream
Parameters:
b - data.
off - offset of the data.
len - length of the data written to the file.
Throws:
java.io.IOException - if fail to write the data.

write

public void write(int b)
           throws java.io.IOException
Write data to the log file. If the size of the file exceeds maximum size of the file, this stream will rename the file to filename + ".arc" and create a new log file. If the file whose name is "filename + ".arc"" already exists, the existing file will be renamed to "filename + ".arc" + date.getMinutes() + date.getHours() + date.getDate() + date.getMonth() + date.getYear()", where date is current date.
Overrides:
write in class java.io.OutputStream
Parameters:
b - integer.
Throws:
java.io.IOException - if fail to write the data.