Hi all, today I have come up with new simple application based on one of my blog referee’s request.
He asked me to code a simple application that will handle audit file. Normally I do not do anyone’s assignments but this done because I didn’t know how to do it in java. So finally I did it. See the code and explanation on the source code for more details.
This is very simple application that will record the every process of the application (login, button click, etc…) to .dat file. In a big project this will very helpful. I did not use any data encryption method here.
This is the audit file handling class /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package simpleaudit; import java.io.*; /** * * @author Developer */ public class Audit{ // this is the start audit class public void auditIt(String message) throws ClassNotFoundException // method declaration { BufferedWriter bw = null; try { //this pease of code i got from //http://www.devdaily.com/java/edu/qanda/pjqa00009.shtml bw = new BufferedWriter(new FileWriter("checkbook.dat", true)); // create a new object bw.write(message); // passed the audit message bw.newLine(); //print new line after each statement bw.flush(); // flush the buffer after enter audit details. } catch (IOException ioe) { } finally { if (bw != null) try { bw.close(); } catch (IOException ioe2) { } } } } see the netbeans project for complete code. Download the Project
did you ever heard about log4j. Apache log4j is a Java-based logging utility. i Think you should follow this method cuz Apache log4j is interesting framework for keeping logging statement.
thanks
Thanks Damith.
You are very best in java.I wish you to be a java expert in time to come.
thanks but i am little in java.
Dear Damith,
When i make jar file for netbeans project, jasper reports are not working via jar.what is the reason for that? Please help me.
Isuru
OK friend,it seems to me that you don’t have jasper report library in to your library folder. You can download it from internet or use this link to download http://www.4shared.com/file/9RK6eml4/jasperreports-371.html
put this library in your “lib” folder.
Let me know you were succeed .happy Java