|
1-Wire Weather Service for Java -- Server API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
wxservice.DailyPrintStream
public class DailyPrintStream
Print stream for managing daily log files.
The following example shows how to redirect System.out
and
System.err
to use DailyPrintStream
:
System.setOut(DailyPrintStream.getInstance()); System.setErr(DailyPrintStream.getInstance());The file name format is "log\yyyy-MM-dd.txt" in the current directory. The log directory must exist.
Field Summary | |
---|---|
private static java.text.Format |
DATE_FORMAT
Formatter for date-time string. |
private static java.io.PrintStream |
m_instance
Singleton instance. |
private long |
m_time
Time of last date check. |
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
private |
DailyPrintStream()
Creates a new instance of PrintStream |
Method Summary | |
---|---|
private void |
checkDate()
Checks the date and creates a new file output stream if necessary. |
static java.io.PrintStream |
getInstance()
Accessor for the single instance of DailyPrintStream . |
void |
write(byte[] buf,
int off,
int len)
This method overrides the standard 3-argument write method. |
void |
write(int b)
This method overrides the standard 1-argument write method. |
Methods inherited from class java.io.PrintStream |
---|
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError |
Methods inherited from class java.io.FilterOutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.text.Format DATE_FORMAT
private static java.io.PrintStream m_instance
private long m_time
Constructor Detail |
---|
private DailyPrintStream() throws java.io.IOException
java.io.IOException
- if file creation fails.Method Detail |
---|
public static java.io.PrintStream getInstance() throws java.io.IOException
DailyPrintStream
.
DailyPrintStream
.
Creates a new instance on the first invocation of this method.
java.io.IOException
- if creation fails.public void write(byte[] buf, int off, int len)
write
in class java.io.PrintStream
buf
- the byte array to print.off
- starting point in the buffer.len
- number of bytes to write.public void write(int b)
write
in class java.io.PrintStream
b
- the byte to write.private void checkDate() throws java.io.IOException
java.io.IOException
- if file creation fails.
|
Copyright © 2005-2008 Karl Uppiano | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |