Read properties files in Spring using context namespace

In this tutorial, I will show you how to read file properties in Spring using the context namespace. But first, let’s create an example project. I will use Java 17 for this example:

Spring framework dependency:

Class Application:

In our example, the… Read More

Convert Java object to JSON using Jackson

Jackson is a standard library for handling JSON-related issues in Java. In this tutorial, we will learn how to convert Java objects to JSON using the Jackson library. First, I will illustrate with a Maven project as follows: Jackson dependency is as follows:

The… Read More

isPresent() method of Optional object in Java

This method will check whether an Optional object is not empty? If this object is empty, it returns false. For example:

Result:

map() method of Optional object in Java

This method first will check whether our Optional object is empty or not? If not empty, convert its value to another value. Similar to the filter() method, this method returns an Optional object with a value after conversion. For example:

In the above example,… Read More