code_junkie

Does new URL(…).openConnection() necessarily imply a POST?

Nov 10th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. URL myURL = new URL("http://example.com/my/path");
  2. URLConnection conn = myURL.openConnection();
  3. conn.setDoOutput(true);
  4. conn.setDoInput(true);
  5.  
  6. OutputStream os = conn.getOutputStream();
  7. os.write("Hi there!");
  8. os.close();
  9.  
  10. InputStream is = conn.getInputStream();
  11. // read stuff here
  12.  
  13. URL myURL = new URL("http://example.com/my/path");
  14. URLConnection conn = myURL.openConnection();
  15. conn.setDoOutput(false);
  16. conn.setDoInput(true);
  17.  
  18. InputStream is = conn.getInputStream();
  19. // read stuff here
Add Comment
Please, Sign In to add comment