HTTPCLIENT / CATATAN</>↗HttpClient17 Mei 2025
To read HTTP responses in Java 11 using HttpResponse.BodyHandlers, you use the Java 11 java.net.http package, which introduced the HttpClient API. The HttpResponse.BodyHandlers class provides various static methods to handle the HTTP response body in different formats, such as strings, files, or byte arrays. Here’s a step-by-step guide to using HttpResponse.BodyHandlers with examples: Step 1: […]
HTTPCLIENT / CATATAN</>↗HttpClient16 Mei 2025
Java 11 introduced the java.net.http package, providing a modern API to work with HTTP. The HttpRequest.BodyPublishers class is part of this package and is used for sending request bodies when creating HTTP requests using HttpClient. Here’s a breakdown of how to use HttpRequest.BodyPublishers effectively in Java 11: 1. Overview of HttpRequest.BodyPublishers HttpRequest.BodyPublishers is a utility […]
HTTPCLIENT / CATATAN</>↗HttpClient16 Mei 2025
In Java 11, you can use the HttpRequest class (from the java.net.http package) to build HTTP requests, including adding query parameters to a URI. Here’s how you can build an HttpRequest with query parameters: Example package org.kodejava.net.http; import java.net.URI; import java.net.URISyntaxException; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpHeaders; import java.net.URLEncoder; import jav...
HTTPCLIENT / CATATAN</>↗HttpClient15 Mei 2025
Java 11 introduced a new HttpClient API (java.net.HttpClient) that simplifies making HTTP requests and handling responses. It provides a clean and concise way to perform synchronous and asynchronous HTTP operations, and it fully supports RESTful APIs. Here’s a step-by-step guide with examples for how to use the Java 11 HttpClient to call REST APIs. 1. […]
HTTPCLIENT / CATATAN</>↗HttpClient15 Mei 2025
Java 11 introduced the HttpClient API to simplify and modernize HTTP communications. This API supports sending requests using different HTTP methods (GET, POST, PUT, DELETE, etc.). Below is an explanation and example of how to perform these operations. 1. Setup You will use the HttpClient and related classes from java.net.http package: HttpClient – To execute […]
CONCURRENCY / CATATAN</>↗Concurrency14 Mei 2025
Writing custom synchronizers with AbstractQueuedSynchronizer (AQS) in Java involves creating classes that encapsulate synchronization logic, such as locks, semaphores, or barriers. AQS simplifies the development of concurrency tools by handling queueing and thread state management. Below are the key steps and guidelines to write custom synchronizers using AbstractQueuedSynchronizer: 1. Understand AQS Concepts state: AQS maintains […]