|
Apologies for my insolent lack of responsibility to keep my post updated. But I found the root cause for the exception that I mentioned. It is not with the file permissions as I, somewhere in my mind, guessed with a positive skepticism but dismissed the thought as soon as it struck me. I was able to create the "Reports" directory but failed while saving the chart. Infact, it was bound to fail as I didn't give the name to the chart!. So here is the solution for it, in case any one may find it useful:
public void saveChartAsJpeg() throws IOException
{
String userDesktop = System.getProperty("user.home") + "\\Desktop\\";
new File(userDesktop + "\\Reports\\").mkdirs();
ChartUtilities.saveChartAsJPEG(new File(userDesktop + "\\Reports\\ChartName.jpg"), constructChart(), 250, 250);
}
Thank you.
|