public class RolloverFileOutputStream
extends java.io.FilterOutputStream
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.
Constructor and Description |
---|
RolloverFileOutputStream(java.lang.String filename) |
RolloverFileOutputStream(java.lang.String filename,
boolean append) |
RolloverFileOutputStream(java.lang.String filename,
boolean append,
int retainDays) |
RolloverFileOutputStream(java.lang.String filename,
boolean append,
int retainDays,
java.util.TimeZone zone) |
RolloverFileOutputStream(java.lang.String filename,
boolean append,
int retainDays,
java.util.TimeZone zone,
java.lang.String dateFormat,
java.lang.String backupFormat) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.lang.String |
getDatedFilename() |
java.lang.String |
getFilename() |
int |
getRetainDays() |
static java.time.ZonedDateTime |
toMidnight(java.time.ZonedDateTime now)
Get the "start of day" for the provided DateTime at the zone specified.
|
void |
write(byte[] buf) |
void |
write(byte[] buf,
int off,
int len) |
public RolloverFileOutputStream(java.lang.String filename) throws java.io.IOException
filename
- The filename must include the string "yyyy_mm_dd",
which is replaced with the actual date when creating and rolling over the file.java.io.IOException
- if unable to create outputpublic RolloverFileOutputStream(java.lang.String filename, boolean append) throws java.io.IOException
filename
- The filename must include the string "yyyy_mm_dd",
which is replaced with the actual date when creating and rolling over the file.append
- If true, existing files will be appended to.java.io.IOException
- if unable to create outputpublic RolloverFileOutputStream(java.lang.String filename, boolean append, int retainDays) throws java.io.IOException
filename
- The filename must include the string "yyyy_mm_dd",
which is replaced with the actual date when creating and rolling over the file.append
- If true, existing files will be appended to.retainDays
- The number of days to retain files before deleting them. 0 to retain forever.java.io.IOException
- if unable to create outputpublic RolloverFileOutputStream(java.lang.String filename, boolean append, int retainDays, java.util.TimeZone zone) throws java.io.IOException
filename
- The filename must include the string "yyyy_mm_dd",
which is replaced with the actual date when creating and rolling over the file.append
- If true, existing files will be appended to.retainDays
- The number of days to retain files before deleting them. 0 to retain forever.zone
- the timezone for the outputjava.io.IOException
- if unable to create outputpublic RolloverFileOutputStream(java.lang.String filename, boolean append, int retainDays, java.util.TimeZone zone, java.lang.String dateFormat, java.lang.String backupFormat) throws java.io.IOException
filename
- The filename must include the string "yyyy_mm_dd",
which is replaced with the actual date when creating and rolling over the file.append
- If true, existing files will be appended to.retainDays
- The number of days to retain files before deleting them. 0 to retain forever.zone
- the timezone for the outputdateFormat
- The format for the date file substitution. The default is "yyyy_MM_dd".backupFormat
- The format for the file extension of backup files. The default is "HHmmssSSS".java.io.IOException
- if unable to create outputpublic static java.time.ZonedDateTime toMidnight(java.time.ZonedDateTime now)
now
- the date time to calculate frompublic java.lang.String getFilename()
public java.lang.String getDatedFilename()
public int getRetainDays()
public void write(byte[] buf) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(byte[] buf, int off, int len) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterOutputStream
java.io.IOException
Copyright © 1995–2017 Webtide. All rights reserved.