I'm pointing to a URL, where there is a hyperlink with down-arrow saying "download files in Zip format".When we click on that hyperlink, files are downloaded.I want to download the files contained in that link using java code.
I tried many ways, followed some of the samples mentioned below.
Download file by passing URL using java code
I'm getting below exception:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL
But when i manually click on the URL, it opens the page where i can see the "download files in Zip" link where i can click and download the files.
java code:
public class UrlDownload{
public static void main(String[] args) throws Exception {
URL oracle = new URL("https://sample.com/view/build/myReports");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
I tried many ways, one of the simple way is mentioned above. The URL i gave here is dummy URL.