簡體   English   中英

JSP將“渲染的”圖像另存為

[英]JSP save “rendered” image as

我有一個根據給定參數生成圖表的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);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM