Top Description Inners Fields Constructors Methods
org.mortbay.util

public Class RolloverFileOutputStream

extends FilterOutputStream
Class Inheritance
Imports
java.io.File, .FileOutputStream, .FilterOutputStream, .IOException, .OutputStream, java.lang.ref.WeakReference, java.text.SimpleDateFormat, java.util.ArrayList, .Calendar, .Date, .GregorianCalendar, .ListIterator, .StringTokenizer, .TimeZone, .Timer, .TimerTask

RolloverFileOutputStream This output stream puts content in a file that is rolled over every 24 hours. The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file. Old files are retained for a number of days before being deleted.
Author
Greg Wilkins

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static Timer
private boolean
private File
private SimpleDateFormat
private SimpleDateFormat
private String
private int
private RolloverFileOutputStream.RollTask
pack-priv static final String
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public
RolloverFileOutputStream(String
The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.
filename
)

public
RolloverFileOutputStream(String
The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.
filename
,
boolean
If true, existing files will be appended to.
append
)

public
RolloverFileOutputStream(String
The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.
filename
,
boolean
If true, existing files will be appended to.
append
,
int
The number of days to retain files before deleting them. 0 to retain forever.
retainDays
)

public
RolloverFileOutputStream(String
The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.
filename
,
boolean
If true, existing files will be appended to.
append
,
int
The number of days to retain files before deleting them. 0 to retain forever.
retainDays
,
TimeZone zone)

public
RolloverFileOutputStream(String
The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.
filename
,
boolean
If true, existing files will be appended to.
append
,
int
The number of days to retain files before deleting them. 0 to retain forever.
retainDays
,
TimeZone zone, String
The format for the date file substitution. If null the system property ROLLOVERFILE_DATE_FORMAT is used and if that is null, then default is "yyyy_MM_dd".
dateFormat
,
String
The format for the file extension of backup files. If null the system property ROLLOVERFILE_BACKUP_FORMAT is used and if that is null, then default is "HHmmssSSS".
backupFormat
)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with the stream.
public String
public String
public int
private void
private synchronized void
public void
write(byte[]
the data to be written.
buf
)

Overrides java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.
public void
write(byte[]
the data.
buf
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
Inherited from java.io.FilterOutputStream:
flushwrite

Field Detail

__rolloverback to summary
private static Timer __rollover
_appendback to summary
private boolean _append
_fileback to summary
private File _file
_fileBackupFormatback to summary
private SimpleDateFormat _fileBackupFormat
_fileDateFormatback to summary
private SimpleDateFormat _fileDateFormat
_filenameback to summary
private String _filename
_retainDaysback to summary
private int _retainDays
_rollTaskback to summary
private RolloverFileOutputStream.RollTask _rollTask
YYYY_MM_DDback to summary
pack-priv static final String YYYY_MM_DD

Constructor Detail

RolloverFileOutputStreamback to summary
public RolloverFileOutputStream(String filename) throws IOException
Parameters
filename:String

The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.

RolloverFileOutputStreamback to summary
public RolloverFileOutputStream(String filename, boolean append) throws IOException
Parameters
filename:String

The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.

append:boolean

If true, existing files will be appended to.

RolloverFileOutputStreamback to summary
public RolloverFileOutputStream(String filename, boolean append, int retainDays) throws IOException
Parameters
filename:String

The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.

append:boolean

If true, existing files will be appended to.

retainDays:int

The number of days to retain files before deleting them. 0 to retain forever.

RolloverFileOutputStreamback to summary
public RolloverFileOutputStream(String filename, boolean append, int retainDays, TimeZone zone) throws IOException
Parameters
filename:String

The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.

append:boolean

If true, existing files will be appended to.

retainDays:int

The number of days to retain files before deleting them. 0 to retain forever.

RolloverFileOutputStreamback to summary
public RolloverFileOutputStream(String filename, boolean append, int retainDays, TimeZone zone, String dateFormat, String backupFormat) throws IOException
Parameters
filename:String

The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when creating and rolling over the file.

append:boolean

If true, existing files will be appended to.

retainDays:int

The number of days to retain files before deleting them. 0 to retain forever.

dateFormat:String

The format for the date file substitution. If null the system property ROLLOVERFILE_DATE_FORMAT is used and if that is null, then default is "yyyy_MM_dd".

backupFormat:String

The format for the file extension of backup files. If null the system property ROLLOVERFILE_BACKUP_FORMAT is used and if that is null, then default is "HHmmssSSS".

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterOutputStream.close.

Closes this output stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
getDatedFilenameback to summary
public String getDatedFilename()
getFilenameback to summary
public String getFilename()
getRetainDaysback to summary
public int getRetainDays()
removeOldFilesback to summary
private void removeOldFiles()
setFileback to summary
private synchronized void setFile() throws IOException
writeback to summary
public void write(byte[] buf) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.

Parameters
buf:byte[]

the data to be written.

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] buf, int off, int len) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
buf:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Exceptions
IOException:
if an I/O error occurs.
org.mortbay.util back to summary

private Class RolloverFileOutputStream.RollTask

extends TimerTask
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

The action to be performed by this timer task.
Inherited from java.util.TimerTask:
cancelscheduledExecutionTime

Constructor Detail

RollTaskback to summary
private RollTask()

Method Detail

runback to summary
public void run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

Doc from java.util.TimerTask.run.

The action to be performed by this timer task.