Hi, this is my code.I am trying to display the html code of google search results.I am using command line arguments to give input.
i have executed like
java Demo
http://www.google.com/search?q=java&hl=en&lr=&start=10&sa=N import java.net.*;
import java.io.*;
class Demo {
public static void main(
String[] args) throws Exception {
URL url = new URL(args[0]);
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent","");
conn.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null)
{
System.out.print(line);
}
}
}
Why this is not working?But when i substitute the query in place of args[0] in the code,it is working.Is there anything to do with encoding?
Can anyone help me?