Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void sendData(List<String> jsonDataPoints) throws IOException {
- for (String json : jsonDataPoints) {
- URL url = new URL(ENDPOINT);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("POST");
- connection.setRequestProperty("Content-Type", "application/json");
- connection.setDoOutput(true);
- DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
- outputStream.writeBytes(json);
- System.out.println("Sending encoded song data to server... ");
- System.out.println(json);
- outputStream.flush();
- int responseCode = connection.getResponseCode();
- System.out.println("Response code: " + responseCode);
- outputStream.close();
- connection.disconnect();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement