@@ -0,0 +1,1392 @@
+package de.asw.java.training2016.net;%0A%0Aimport java.io.PrintStream;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.URL;%0Aimport java.net.URLConnection;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Scanner;%0A%0Apublic class UrlConnectionHttpPostRequestExample %7B%0A%0A%09public static void main(String%5B%5D args) throws Exception %7B%0A%0A%09%09HttpURLConnection urlConnection = (HttpURLConnection) new URL(%22https://httpbin.org/post%22).openConnection();%0A%09%09urlConnection.setRequestProperty(%22Content-Type%22, %22application/json%22);%0A%09%09urlConnection.setDoOutput(true);%0A%09%09urlConnection.setRequestMethod(%22POST%22);%0A%0A%09%09PrintStream requestBody = new PrintStream(urlConnection.getOutputStream());%0A%09%09requestBody.print(%22%7B%5C%22foo%5C%22:%5C%22bar%5C%22%7D%22);%0A%0A%09%09try (Scanner scanner = new Scanner(urlConnection.getInputStream())) %7B%0A%09%09%09printResponseHeaders(urlConnection);%0A%09%09%09printResponseBody(scanner);%0A%09%09%7D%0A%0A%09%09urlConnection.disconnect();%0A%09%7D%0A%0A%09private static void printResponseHeaders(URLConnection urlConnection) %7B%0A%09%09for (Map.Entry%3CString, List%3CString%3E%3E header : urlConnection.getHeaderFields().entrySet()) %7B%0A%09%09%09if (header.getKey() == null) %7B%0A%09%09%09%09System.out.println(header.getValue().get(0));%0A%09%09%09%09continue;%0A%09%09%09%7D%0A%09%09%09System.out.printf(%22%25s: %25s%25n%22, header.getKey(), header.getValue());%0A%09%09%7D%0A%09%7D%0A%0A%09private static void printResponseBody(Scanner scanner) %7B%0A%09%09while (scanner.hasNextLine()) %7B%0A%09%09%09System.out.println(scanner.nextLine());%0A%09%09%7D%0A%09%7D%0A%7D

Add example for sending http post request via UrlConnection