|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.directj.jlogger.FileOutput
This is a simple class that print logging information into a file. The jlogger tool has the particularity that an information can be write at any moment. Because of that, using specific format that need a footer, like XML or HTML can be quite complex, and need some methods like 'stop' or 'close' that is not compatible with the jlogger's objectives. So this class use a RandomAccessFile and re-write the footer for each new information. This way can appear to be a 'barbarian' one, but it is really the more simple for the user (he don't have to take care of ending or closing the file) and it is not really less efficient than a 'classic' way. WARNING: This class just print the specified string, but without a nl character. The formatter HAVE TO take care of 'nl' ('\n' in java) char.
Nested Class Summary | |
private class |
FileOutput.ShutdownHook
This class is used to close the file at the end of the JVM. |
Field Summary | |
private java.lang.String |
fileName
The file name. |
private byte[] |
footer
The footer string, as an array of bytes. |
private byte[] |
header
The header string, as an array of bytes. |
private java.io.RandomAccessFile |
out
The output stream. |
private long |
skip
Indicate te number of bytes to skip. |
Constructor Summary | |
FileOutput()
Creates a new FileOutput. |
|
FileOutput(java.lang.String _name)
Creates a new FileOutput, with a specified name. |
|
FileOutput(java.lang.String _name,
boolean _append)
Creates a new FileOutput, with a specified name. |
|
FileOutput(java.lang.String _name,
java.lang.String _header,
java.lang.String _footer,
boolean _append)
Creates a new FileOutput, with a specified name. |
Method Summary | |
boolean |
equals(java.lang.Object _obj)
Indicates whether some other object is "equal to" this one. |
int |
hashCode()
Returns a hash code value for the object. |
void |
print(java.lang.String _str)
Prints the info, using the output. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.io.RandomAccessFile out
private java.lang.String fileName
private byte[] header
private byte[] footer
private long skip
Constructor Detail |
public FileOutput()
public FileOutput(java.lang.String _name)
_name
- The file name, with the extension.public FileOutput(java.lang.String _name, boolean _append)
_name
- The file name, with the extension._append
- Indicates if we append the output to the file or create a new one.public FileOutput(java.lang.String _name, java.lang.String _header, java.lang.String _footer, boolean _append)
_name
- The file name, with the extension._header
- The header string._footer
- The footer string._append
- Indicates if we append the output to the file or create a new one. If the
file does not exists, this has no effects.Method Detail |
public void print(java.lang.String _str)
print
in interface Output
_str
- The debugging info to print on the output.Formatter
public boolean equals(java.lang.Object _obj)
equals
in class java.lang.Object
_obj
- The reference object with which to compare.
boolean
- True if this object is the same as the obj argument; false otherwise.public int hashCode()
hashCode
in class java.lang.Object
int
- A hash code value for this object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |