public class RolloverFileOutputStream extends 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.
out
Constructor and Description |
---|
RolloverFileOutputStream(String filename) |
RolloverFileOutputStream(String filename,
boolean append) |
RolloverFileOutputStream(String filename,
boolean append,
int retainDays) |
RolloverFileOutputStream(String filename,
boolean append,
int retainDays,
TimeZone zone) |
RolloverFileOutputStream(String filename,
boolean append,
int retainDays,
TimeZone zone,
String dateFormat,
String backupFormat) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
getDatedFilename() |
String |
getFilename() |
int |
getRetainDays() |
static ZonedDateTime |
nextMidnight(ZonedDateTime dateTime)
Get the next "start of day" for the provided date.
|
static ZonedDateTime |
toMidnight(ZonedDateTime dateTime,
ZoneId zone)
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) |
flush, write
public RolloverFileOutputStream(String filename) throws 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.IOException
- if unable to create outputpublic RolloverFileOutputStream(String filename, boolean append) throws 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.IOException
- if unable to create outputpublic RolloverFileOutputStream(String filename, boolean append, int retainDays) throws 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.IOException
- if unable to create outputpublic RolloverFileOutputStream(String filename, boolean append, int retainDays, TimeZone zone) throws 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 outputIOException
- if unable to create outputpublic RolloverFileOutputStream(String filename, boolean append, int retainDays, TimeZone zone, String dateFormat, String backupFormat) throws 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".IOException
- if unable to create outputpublic static ZonedDateTime toMidnight(ZonedDateTime dateTime, ZoneId zone)
dateTime
- the date time to calculate fromzone
- the zone to return the date inpublic static ZonedDateTime nextMidnight(ZonedDateTime dateTime)
dateTime
- the date to calculate frompublic String getFilename()
public String getDatedFilename()
public int getRetainDays()
public void write(byte[] buf) throws IOException
write
in class FilterOutputStream
IOException
public void write(byte[] buf, int off, int len) throws IOException
write
in class FilterOutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterOutputStream
IOException
Copyright © 1995–2017 Webtide. All rights reserved.