{"id":1078,"date":"2022-08-30T15:12:01","date_gmt":"2022-08-30T15:12:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/error-when-attempt-to-load-image-using-imageio-read-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:12:01","modified_gmt":"2022-08-30T15:12:01","slug":"error-when-attempt-to-load-image-using-imageio-read-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/error-when-attempt-to-load-image-using-imageio-read-collection-of-common-programming-errors\/","title":{"rendered":"Error when attempt to load image using ImageIO.read-Collection of common programming errors"},"content":{"rendered":"<p>After searching for similar questions I would like to ask the following question:<\/p>\n<p>I am trying to load a picture from Google Static Maps, but I get this error:<code>Exception in thread \"main\" java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(Unknown Source) at MapPicturePanel.main(MapPicturePanel.java:18)<\/code><\/p>\n<p>The following is the full code of this class:<\/p>\n<pre><code> import java.awt.image.BufferedImage;\nimport java.io.IOException;\nimport java.net.URL;\nimport javax.imageio.ImageIO;\nimport javax.swing.*;\n\npublic class MapPicturePanel {\n    private JScrollPane getContent(BufferedImage image) {\n        ImageIcon icon = new ImageIcon(image);\n        JLabel label = new JLabel(icon);\n        label.setHorizontalAlignment(JLabel.CENTER);\n        return new JScrollPane(label);\n    }\n\n    public static void main(String[] args) throws IOException {\n        String path = \"http:\/\/maps.googleapis.com\/maps\/api\/staticmap?center=37.426616,-122.176380&amp;zoom=14&amp;size=800x600&amp;scale=2&amp;format=jpg&amp;maptype=hybrid&amp;sensor=false\";\n        URL url = MapPicturePanel.class.getResource(path);\n        BufferedImage image = ImageIO.read(url);\n        JFrame f = new JFrame();\n        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n        f.setContentPane(new MapPicturePanel().getContent(image));\n        f.setSize(800,800);\n        f.setLocation(200,200);\n        f.setVisible(true);\n    }\n}\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:21:53. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>After searching for similar questions I would like to ask the following question: I am trying to load a picture from Google Static Maps, but I get this error:Exception in thread &#8220;main&#8221; java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(Unknown Source) at MapPicturePanel.main(MapPicturePanel.java:18) The following is the full code of this class: import java.awt.image.BufferedImage; import java.io.IOException; import [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1078","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1078"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1078\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}