Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void post(String url) throws Exception {
- URL u = new URL(url);
- URLConnection c = u.openConnection();
- c.setDoOutput(true);
- if (c instanceof HttpURLConnection) {
- ((HttpURLConnection)c).setRequestMethod("POST");
- }
- OutputStreamWriter out = new OutputStreamWriter(
- c.getOutputStream());
- // output your data here
- out.close();
- BufferedReader in = new BufferedReader(
- new InputStreamReader(
- c.getInputStream()));
- String s = null;
- while ((s = in.readLine()) != null) {
- System.out.println(s);
- }
- in.close();
- }
Add Comment
Please, Sign In to add comment