CORE API / CATATAN</>↗Core API04 Jan 2024
The java.nio.file.Files.lines() method is a Java NIO method used to read the contents of a file line by line. The code snippet will read the file from the specified filePath and print each line to the console. The Files.lines() method returns a Stream of strings, and we use Stream’s forEach method to print each line. […]
BASIC / CATATAN</>↗Basic29 Des 2023
Method references in Java are a feature that was introduced in Java 8. They provide a way to refer to a method without actually executing it. They are often used in conjunction with Java’s functional programming features, such as Streams and Lambdas, where a method to be executed is often expected as a parameter. The […]
JAVA 8 / CATATAN</>↗Java 828 Des 2023
You can sort strings based on their length using the sort method combined with a custom comparator. In the code snippet below we are going to use the Arrays.sort() method. We pass an array of string to the sort() method and also a lambda expression as the custom comparator. Here is how you’d do it […]
JAVA 8 / CATATAN</>↗Java 823 Des 2023
In the previous example, How do I convert an image file to a Base64 string?, you’ve seen how to convert image file to base64 string. In this example, you will see how you can convert a base64 string back into an image file. Below are examples of how to do this in Java, using the […]
JAVA 8 / CATATAN</>↗Java 822 Des 2023
A Base64 string is a way of encoding binary data using 64 printable characters, which are the 26 uppercase letters of the English alphabet, the 26 lowercase letters of the English alphabet, the 10 numerical digits, and the “+” and “/” symbols. This makes a total of 64 distinct characters, hence the name “Base64”. Base64 […]
APACHE POI / CATATAN</>↗Apache POI09 Des 2023
Apache POI is a robust open-source library that provides APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft’s OLE2 compound document format (OLE2). Being Java-based, it’s readily used by Java developers for creating, reading, and modifying Excel files. To create a new Excel file using Apache POI, you […]