Server returned HTTP response code: 501

The following code return

Server returned HTTP response code: 501 for URL: http://www.google.com/search

please help me in this regard

import java.net.*;

import java.io.*;

publicclass Test{

publicstaticvoid main (String args[])

{

try{

// Construct data

String data = URLEncoder.encode("hl","UTF-8") +"=" + URLEncoder.encode("en","UTF-8");

data +="&"+ URLEncoder.encode("q","UTF-8") +"=" + URLEncoder.encode("affiliate marketing","UTF-8");

data +="&"+ URLEncoder.encode("btnG","UTF-8") +"=" + URLEncoder.encode("Google Search","UTF-8");

data +="&"+ URLEncoder.encode("meta","UTF-8") +"=" + URLEncoder.encode("","UTF-8");

// Send data

URL url =new URL("http://www.google.com/search");

URLConnection conn = url.openConnection();

System.out.println("1");

conn.setDoOutput(true);

System.out.println("2");

OutputStreamWriter wr =new OutputStreamWriter(conn.getOutputStream());

System.out.println("3");

wr.write(data);

wr.flush();

// Get the response

BufferedReader rd =new BufferedReader(new InputStreamReader(conn.getInputStream()));

String line;

while ((line = rd.readLine()) !=null){

System.out.println(line);

}

wr.close();

rd.close();

}

catch (Exception e)

{

System.out.println(e.getMessage());

System.out.println(e.getStackTrace());

}

}

}

[3058 byte] By [Neem-Baz-Aankhaina] at [2007-11-27 2:45:28]
# 1
Not implemented 501The server does not support the facility required. This will give your solution. http://csis.pace.edu/~bergin/Java/googlesearch.html
polimetlaa at 2007-7-12 3:13:03 > top of Java-index,Core,Core APIs...