I'm trying to download images from url but got java.io.IOException: exception. My code is:
public static void main(String[] args) throws MalformedURLException, IOException {
File picutreFile = new File("test.jpg");
FileUtils.copyURLToFile(new java.net.URL("http://paceoil.ca/files/includes/images/images-stories-presentation-october-icon-graphic.jpg"), picutreFile);
}
When run threw :
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://paceoil.ca/files/includes/images/images-stories-presentation-october-icon-graphic.jpg
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1460)
at com.hrant.Test.main(Test.java:14)
This code works for some urls but for this I couldnt understand why not. Advance many Thanks.