Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public String sendData(String URL, String message) throws IOException {
  2.         URL url = new URL(URL);
  3.         URLConnection connection = url.openConnection();
  4.         connection.setDoOutput(true);
  5.         DataOutputStream printout = new DataOutputStream(
  6.                 connection.getOutputStream());
  7.         printout.writeBytes(message);
  8.         printout.flush();
  9.         printout.close();
  10.         BufferedReader in = new BufferedReader(new InputStreamReader(
  11.                 connection.getInputStream()));
  12.         String returnData = "";
  13.         String temp;
  14.         while ((temp = in.readLine()) != null) {
  15.             returnData += temp + "\n";
  16.         }
  17.         return returnData;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement