set Request Body for HttpURLConnection - Android Network

Android examples for Network:HTTP Request

Description

set Request Body for HttpURLConnection

Demo Code


//package com.java2s;

import java.io.DataOutputStream;
import java.io.IOException;

import java.net.HttpURLConnection;

public class Main {
    public static void setRequestBody(HttpURLConnection conn, String body)
            throws IOException {
        DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
        dos.writeUTF(body);/* ww w . ja va2s  .c om*/
    }
}

Related Tutorials