CORE API / CATATAN</>↗Core API02 Apr 2025
Streaming large files over a network using sockets in Java requires splitting the file into manageable chunks to avoid memory overhead, as well as safely reading and transmitting data between the client and server. Below is a step-by-step guide with code to demonstrate how to achieve this. Key Steps: Open a file stream to read […]
CORE API / CATATAN</>↗Core API01 Apr 2025
Handling HTTP redirects in Java using HttpURLConnection is fairly straightforward. It involves processing the HTTP response code and manually following the redirection if the server responds with a 3xx status code. Here’s a step-by-step guide: 1. Set up the HTTP connection: Create a HttpURLConnection instance and configure it for the initial request. Set the allowed […]
CORE API / CATATAN</>↗Core API31 Mar 2025
You can use Java’s InetAddress class to check internet connectivity and ping a server directly. Here is how you can do it: Steps to check internet connectivity and ping a server: Use InetAddress.getByName(String host) or InetAddress.getByAddress(…) to get the address of the host/server you want to ping. Use the isReachable(int timeout) method to test if […]
CORE API / CATATAN</>↗Core API30 Mar 2025
In Java, you can use the URLEncoder and URLDecoder classes to handle URL encoding and decoding. These classes are part of the java.net package and are often used to ensure that special characters in URLs are properly encoded so they can be safely transmitted over the web. For decoding, you can convert encoded URLs back […]
CORE API / CATATAN</>↗Core API29 Mar 2025
In Java, the CookieManager and CookieHandler classes from the java.net package are used for handling HTTP cookies. They allow you to manage cookies for actions such as sending cookies with HTTP requests or maintaining sessions between HTTP communications. Steps to Use CookieManager and CookieHandler Set a Global CookieManager: The CookieHandler class is an abstract class, […]
CORE API / CATATAN</>↗Core API28 Mar 2025
To implement secure socket communication using SSLSocket and SSLServerSocket in Java, you need to utilize the Java Secure Sockets Extension (JSSE) API, which provides support for the SSL/TLS protocols. Below is a step-by-step guide: 1. Key Concepts SSL/TLS provides encryption and ensures secure communication between a client and server. You need: A keystore on the […]