Tuesday, May 19, 2009

Exception Log file generator.

//This is a static function to save the exception in a file.

public static boolean writeToFile(String text)
{
Date recentdate=Calendar.getInstance().getTime();
logger=new File("C:\\File_Name.txt");
try {
FileWriter fw = new FileWriter(logger, true);
fw.write("\n"+recentdate+": "+text);
fw.flush();
fw.close();
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex);
return false;
}

return true;
}

No comments:

Post a Comment