Can't get input stream from url error java

I made a program in selenium that extracts links of some images from a website so after extraction of link i wanted to save all those images in a folder so i wrote a little code for that

I made a program in selenium that extracts links of some images from a website so after extraction of link i wanted to save all those images in a folder so i wrote a little code for that

for(int j=0; j<links.size(); j++) {
                 URL imageURL = new URL(linklist[j]);
                 BufferedImage saveImage = ImageIO.read(imageURL);
                 ImageIO.write(saveImage, "png", new File("C:\\Users\\Dumpty\\Desktop\\Output\\logo-forum"+ j +".png"));
        }

and yeah im using array to store the url's and for confirmation i printed all the links with this code

for(int k=0; k<links.size(); k++) {
            System.out.println(linklist[k]);
        }

all seems to be working fine but in extraction im facing problem, im getting Can't get input stream from URL! Error I also tried this Can't get input stream from URL! Java but it's still not working this is the full view of the error im getting

Exception in thread "main" javax.imageio.IIOException: Can't get input stream from URL!
    at javax.imageio.ImageIO.read(Unknown Source)
    at com.phantomjs.phantomJStest.main(phantomJStest.java:58)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://lh3.googleusercontent.com/f_kendBNnYqba-mMV-3ItGZ2zzbChaaV22nE4uaEW92EWtXPzvFYwDk82AKQ6YlOru4=w1440-h620 2x
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at java.net.URL.openStream(Unknown Source)
    ... 2 more


How to work on Selenium LIVE Project | Selenium Projects For Beginners

How to work on Selenium LIVE Project | Selenium Projects For Beginners

🔥Intellipaat Selenium WebDriver Course: https://intellipaat.com/selenium-training/ In this selenium projects for beginners you will learn how to work on sele...

In this selenium projects for beginners you will learn how to work on selenium LIVE project step by step.

Why should you watch this Selenium tutorial?

Selenium is a powerful yet open source testing platform that is being used extensively by some of the largest corporations in the world. We are offering the top Selenium tutorial to gain knowledge in software testing. Our Selenium course has been created with extensive inputs from the industry experts so that you can learn Selenium and apply it for real world scenarios.

Selenium WebDriver with C# Tutorial for Beginners

Selenium WebDriver with C# Tutorial for Beginners

Selenium is the most popular tool to test websites! Join me and thousands of students to learn Selenium Webdriver!


Selenium is a free automation testing tool for web applications. It is able to work with different browsers like Chrome, Firefox, IE, Opera and simulate human like behavior. Selenium is able to interact with all the different elements in a webpage. It can click on them, input text, extract text and much more. By covering all the different functionalities on your website with Selenium tests, you will be able to quickly catch new and reappearing old bugs. This will save your team time and money.

Specially for you, I have prepared a website where you can play around and practice your skills.

The website has special elements designed specificly for the course and for you to be able to easily work with them and learn.

In this course we will focus on Graphic User Interface and Functionality Testing and we will learn how to work with the various selectors that Selenium offers us to use like:

  • Name selector
  • ID Selector
  • Class Name selector
  • CSS Path selector
  • X Path selector

After that we will learn how to work with some special elements like:

  • Input text boxes
  • Check boxes
  • Radio buttons
  • Drop down menus
  • JavaScript Alert boxes

We will also have a few theory lectures in which I will explain when you should use either of these selectors, how to inspect elements and what is an Automation Testing Framework and why do we need to learn how to create one.


Learn More

C# Basics for Beginners - Learn C# Fundamentals by Coding

C# Intermediate: Classes, Interfaces and OOP

Complete C# Unity Developer 2D: Learn to Code Making Games

Full Stack Developers: Everything You Need to Know

VS Code extensions you may not have heard of before