Spark Java with Hibernate and MySql database example

In practical scenario it is very common to integrate a database with the web service application. Here we will see an example to use Hibernate to store and retrieve data in Spark Java application. We will use MySql database behind the Hibernate. The application provides HTML based UI for entering and viewing data. Gradle is our build tool here. In case Maven is your favourite build tool, just let me know.

How to join list of string using delimiter in Java

1. Join list of strings using Java 8 String.join(…) If we use Java 8, it is very easy to join a list or array of strings using a delimiter. For a common situation like building a CSV line, this approach is very easy and straightforward. List<String> stringList = new ArrayList<>(); stringList.add("Name"); stringList.add("Sex"); stringList.add("eMail"); stringList.add("Phone"); stringList.add(null); String line = String.join(", ", stringList); System.out.println(line); Output: Name, Sex, eMail, Phone, null