Code example for HttpURLConnection

Methods: connect, getInputStream, getResponseCode, getResponseMessage, setDoInput, setDoOutput, setRequestMethod

0
			try { 
				url = new URL("http://twitter.com/statuses/mentions.xml");
				//url = new URL("http://api.twitter.com/1/statuses/update.xml"); 
				 
				HttpURLConnection request = (HttpURLConnection) url.openConnection();
				request.setRequestMethod("GET");
				 
				//request.setRequestMethod("POST"); 
				request.setDoOutput(true);
				request.setDoInput(true);
				//BufferedReader br = new BufferedReader(request.getInputStream()); 
			 
  			//request.addRequestProperty("status", "firstandroidjittrstatus"); 
				//request. 
				 // sign the request 
		        consumer.sign(request);
		        // send the request 
		        request.connect();
		     
		      //  BufferedReader br = new BufferedReader(new InputStreamReader(request.)); 
		       
		    	//InputStream i = request.getInputStream(); 
		        // response status should be 200 OK 
		        int sc = request.getResponseCode();
                if (sc == 200) {
                    String rm = request.getResponseMessage();
                	System.out.println("Succeed on cal l" + sc);
                	BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
                	String in;
                	System.out.println("test");
                	//while ((in = br.readLine()) != null) { 
                	//	System.out.print(in); 
                	//}  //while