I am creating a Java application that will download an HTML page from a website and save the file on my local system. I can manually access the URL of a webpage through a browser. But when I try to access the same URL in my Java program, the server returns error 503. Here's the script:
sample URL = http://content.somesite.com/demo/somepage.asp
Ability to access the above URL through a browser. But the Java code below cannot load the page:
StringBuffer data = new StringBuffer();
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(sourceUrl.openStream()));
String inputLine = "";
while ((inputLine = br.readLine()) != null) {
data.append(inputLine);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
br.close();
}
So my questions are: