我有一个根据给定参数生成图表的servlet。
我需要能够将那些图表作为常规图像保存在服务器中:例如myImage.png。
这些图表是使用以下代码创建的:
http://127.0.0.1:8080/servlet/graficadorPS?type=area&val1=32.0|32.0|38.0|92.0&cat1=y|y|y|y&eje1=D|I|S|C&titulo=HF&ancho=130&alto=260
因此,“本身”的图像在任何地方都不存在。
有没有办法做到这一点??
样例代码
public static void main(String[] args) throws NumberFormatException, IOException, ParseException {
URL url = new URL("http://cdn.portableapps.com/GoogleChromePortable_128.png");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
InputStream is = conn.getInputStream();
BufferedImage image = ImageIO.read(is);
OutputStream os = new FileOutputStream(new File("output.png"));
ImageIO.write(image, "png", os);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句