import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Tests {
    public static void main(String[] args) throws IOException {
        URL url = new URL(
                "http://www.oracle.com"); //server be that is giving non-100 status response for each server call.
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("PUT");
        conn.setRequestProperty("Expect", "100-continue");
        sendRequest(conn);
        System.out.println("Response code: "+conn.getResponseCode());
        System.out.println("Response Message: "+conn.getResponseMessage());
    }

    private static void sendRequest ( final HttpURLConnection conn)
            throws IOException {
        OutputStream os = null;
        conn.setDoOutput(true);
        conn.setFixedLengthStreamingMode(10);
        byte[] bytes = new byte[10];
        try {
            os = conn.getOutputStream();
            os.write(bytes);
        } catch (Exception e) {}
        if (os != null) {
            os.close();
        }
    }
}