How do you modify http header?
Hi
I am using the following code to connect to different web sites but some will accept the connection
and some won't. I believe that the ones that won't will not do it because the JVM is not sending
the correct header info.
Code:
Vector vect = new Vector();
String filename = "htmpage.html";
String url = "http://www.genericwebsite.com";
// THE NEXT CODE TRYS TO LOOK UP PAGE AND SAVE IN A FILE
URL myurl = new URL(url);
FileWriter fw = new FileWriter(filename);
BufferedReader in = new BufferedReader(
new InputStreamReader(
myurl.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
vect.addElement(inputLine);
fw.write(inputLine);
}
fw.close();
I believe that one of the things I have to do is set the User-Agent but don't know how to do this.
Can anyone help? Thanks in advance.