CORE API / CATATAN</>↗Core API04 Des 2012
In JDK 7 we can write all lines from a List of String into a file using the Files.write() method. We need to provide the Path of the file we want to write to, the List of strings and the charsets. Each line is a char sequence and is written to the file in sequence […]
CORE API / CATATAN</>↗Core API30 Nov 2012
This example you’ll learn how to get file’s basic attributes. Basic file attributes are attributes that are common to many file systems and consist of mandatory and optional file attributes as defined by the BasicFileAttributes interface. The file’s basic attributes include file’s date time information such as the creation time, last access time, last modified […]
CORE API / CATATAN</>↗Core API30 Nov 2012
In the following code snippet you will learn how to update file’s last modified date/time. To update the last modified date/time you can use the java.nio.file.Files.setLastModifiedTime() method. This method takes two arguments. The first arguments is a Path object that represent a file, and the second arguments is the modified date in a FileTime object. […]
CORE API / CATATAN</>↗Core API28 Nov 2012
In this code snippet you’ll learn how to reverse the order of array elements. To reverse to element order will be using the Collections.reverse() method. This method requires an argument with List type. Because of this we need to convert the array to a List type first. We can use the Arrays.asList() to do the […]
APACHE HTTPCOMPONENTS / CATATAN</>↗Apache HttpComponents27 Nov 2012
The following code snippet will show you how to send an HTTP post request using the Apache HttpComponents. We will send a post request to https://httpbin.org/post, with some parameters to the request using the NameValuePair object. To pass these parameters to the HTTP post request we create an instance of UrlEncodedFormEntity and pass a list […]
APACHE HTTPCOMPONENTS / CATATAN</>↗Apache HttpComponents26 Nov 2012
Below is an example using HttpClient library to retrieve the response of HTTP GET request. We start by creating an instance of CloseableHttpClient class. We then define an HTTP GET request by create an instance of HttpGet class and specify the Url of a website we are going to retrieve. To execute the request we […]