Search code examples
javajakarta-eejfreechart

Saving JFreeChart chart to a specific directory


Is there a way to use JFreeChart to save to a specific directory rather than

ChartUtilities.saveChartAsPNG("image.png", chart, 600, 300);

saving to the current directory?

Thanks!


Solution

  • Have you tried putting a full image path in your filename string rather than just "image.png"?

    ChartUtilities.saveChartAsPNG(new File("C:/\path/\to/\picture/\folder/\image.png"), chart, 600, 300);