- ajaxiontest1.0_net1.1_src.zip
- AjaxionTest
- ajaxiontest1.0_net2.0_src.zip
- ajaxiontest1.0_java_src.zip
- ajaxionTest.jpr
- ajaxionTest.jpr.bak
- AjaxionTest.jws
- classes
- ajaxionTest.cdi
- pw
- ajaxion
- AjaxionEventConsumer.class
- log
- FileLog.class
- servlet.cdi
- servlet
- ajaxionTest.class
- public_html
- pw.ajaxion
- classes
- pw.ajaxion.cdi
- pw
- ajaxion
- AjaxionEventConsumer.class
- AjaxionEventHandler.class
- pw.ajaxion.jpr
- src
- pw
- ajaxion
- pw.log
- classes
- audit.log
- pw.log.cdi
- pw
- log
- FileLog.class
- test
- pw.log.jpr
- src
- src
- servlet
|
package pw.log;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;
public class FileLog
{
private static String Write(String fileName, String message, Boolean useLn)
{
String unitTestMessage = null;
try
{
FileOutputStream fo = new FileOutputStream(fileName, true);
try
{
if (useLn)
new PrintStream(fo).println("[" + new Date().toString() + "] " + message);
else
new PrintStream(fo).print("[" + new Date().toString() + "] " + message);
fo.flush();
fo.close();
}
finally
{
if (fo != null)
fo.close();
}
}
catch (Exception ex)
{
unitTestMessage = "FileLog.Write exception : " + ex.getMessage();
System.out.println(unitTestMessage);
}
return unitTestMessage;
}
private String fileName;
public String getFileName()
{
return fileName;
}
public static String Write(String fileName, String message)
{
return Write(fileName, message, false);
}
public static String WriteLn(String fileName, String message)
{
return Write(fileName, message, true);
}
public FileLog()
{
fileName = initFileName();
}
public FileLog(String fileName)
{
this.fileName = fileName;
}
private String initFileName()
{
return getClass().getProtectionDomain().getCodeSource().getLocation().getPath() + "_audit.txt";
}
public String write(String fileName, String message)
{
return Write(fileName, message, false);
}
public String writeLn(String fileName, String message)
{
return Write(fileName, message, true);
}
public String write(String message)
{
if (fileName == null)
fileName = initFileName();
return Write(fileName, message, false);
}
public String writeLn(String message)
{
if (fileName == null)
fileName = initFileName();
return Write(fileName, message, true);
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.