跟踪一下源代码:
![jfreeChart生成图片的保存 - aijun980204 - 学习空间 程序代码](https://i-blog.csdnimg.cn/blog_migrate/588abf745032d4d6e5650c12242948d7.png)
String filename=ServletUtilities.saveChartAsJPEG(chart1,600,400,session);
public static String saveChartAsJPEG(JFreeChart chart, int width,
int height, ChartRenderingInfo info, HttpSession session)
throws IOException {
if (chart == null) {
throw new IllegalArgumentException("Null 'chart' argument.");
}
ServletUtilities.createTempDir();
String prefix = ServletUtilities.tempFilePrefix;
if (session == null) {
prefix = ServletUtilities.tempOneTimeFilePrefix;
}
File tempFile = File.createTempFile(prefix, ".jpeg",
new File(System.getProperty("java.io.tmpdir")));
ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info);
if (session != null) {
ServletUtilities.registerChartForDeletion(tempFile, session);
}
return tempFile.getName();
}
System.getProperty("java.io.tmpdir")得到的路径为:
C:\Program Files\Apache Software Foundation\Tomcat 6.0\temp