how to load a image from web in java

后端 未结 4 2179
[愿得一人]
[愿得一人] 2020-12-28 14:57

I need to load an image from a web in a simple Java stand alone aplication. Any Ideas?

4条回答
  •  天命终不由人
    2020-12-28 15:47

    I would take a look at HTTPClient.

    Find the URL to the image, and you can get an inputstream feeding you the image data, plus you'll get the content-type etc. so you can correctly handle it once you've downloaded it.

    Here's some sample code. You may also need to call getResponseHeaders() on the GetMethod to identify the image type.

提交回复
热议问题