Getting Image from URL (Java)
image, java, url
Solution
You are getting an `HTTP 400` (Bad Request) error because there is a `space` in your URL. If you fix it (before the `zoom` parameter), you will get an `HTTP 401` error (Unauthorized). Maybe you need some HTTP header to identify your download as a recognised browser (use the "User-Agent" header) or additional authentication parameter.
For the User-Agent example, then use the ImageIO.read(InputStream) using the connection inputstream:
URLConnection connection = url.openConnection();
connection.setRequestProperty("User-Agent", "xxxxxx");
Use whatever needed for `xxxxxx`
Problem
I am trying to read the following image But it is showing IIOException. Here is the code: ``` Image image = null; URL url = new URL("http://bks6.books.google.ca/books?id=5VTBuvfZDyoC&printsec=frontcover&img=1& zoom=5&edge=curl&source=gbs_api"); image = ImageIO.read(url); jXImageView1.setImage(image); ```