How can I cast or initialize an ImageInputStream with an InputStream?

I am developing an image cleaning application. I get the url

URL imageUrl = new URL(imageSource); 

Then I create an InputStream with this URL:

 InputStream is = new URL(imageUrl.toString()).openStream(); 

After that, I want to create an ImageInputStream to define ImageIO readers.

 ImageInputStream iis = ?????? 

But I could not initialize this. Can I implement a URL or InputStream for ImageInputStream?

+6
source share
2 answers

this is what you are looking for:

 ImageInputStream iis = ImageIO.createImageInputStream(is); 
+8
source

Best to use ImageIO.read(url) which returns BufferedReader

0
source

Source: https://habr.com/ru/post/921133/


All Articles