jueves, 30 de enero de 2014

Post data in body part

try {
  URL url = new URL("http://requestb.in/14a9s7m1");
     HttpURLConnection conn;
      conn = (HttpURLConnection) url.openConnection();
     conn.setRequestMethod("POST");
     
      conn.setDoOutput(true);
     
  
     OutputStream os = null;
     try {
      os = conn.getOutputStream();
      os.write("fkdlsakl!".getBytes());
   } catch (Exception e) {
      e.printStackTrace();
     }   
     os.close();
     
     conn.connect();
      int respCode = conn.getResponseCode();
  
      if(respCode == 200) {
       InputStream ip = conn.getInputStream();
//       response.headers = conn.getHeaderFields();
       int s = ip.read();
       ip.close();
      }
  } catch (Exception e) {}

No hay comentarios:

Publicar un comentario