Guest User

Untitled

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. StreamConnection s = (StreamConnection) Connector
  2. .open(connectionString);
  3. httpConn = (HttpConnection) s;
  4. httpConn.setRequestMethod("POST");
  5. httpConn.setRequestProperty("Content-Length", Integer.toString(postData.length()));
  6.  
  7. OutputStream output = httpConn.openOutputStream();
  8. output.write(postData.getBytes());
  9. output.flush();
  10. output.close();
  11.  
  12. String response = httpConn.getResponseMessage();
  13. int statusCode = httpConn.getResponseCode();
  14. if (statusCode != HttpConnection.HTTP_OK) {
  15. }
  16.  
  17. InputStream is = httpConn.openInputStream();
  18. int ret = 0;
  19. while ((ret = is.read(buf)) > 0) {
  20. os.write(buf, 0, ret);
  21. }
  22.  
  23. result = new String(os.toByteArray());
  24.  
  25. ConnectionFactory cf = new ConnectionFactory();
  26. ConnectionDescriptor cd = cf.getConnection("YourUrl");
  27. httpConnector = (HttpConnection) cd.getConnection();
  28. httpConnector.setRequestMethod(HttpConnection.POST);
Add Comment
Please, Sign In to add comment