How To Pretty Print JSON In Java

Table of Contents Introduction Why do you need to pretty print JSON data? Prerequisites pretty Print JSON Using Jackson Library Using Google GSON Library Using JSON Library Source Code Introduction Here I am going to show you how to pretty print JSON in Java. I am going to use here JSON, Jackson and Google Gson libraries to prettify the JSON…

How to convert PDF File to CSV File using iText API in Java

In this example I going to show you how to convert PDF file to CSV file. I will read the PDF file using iText library and write data to the CSV file using Java programming language. In my previous example I had shown how to convert CSV file to PDF file using iText library. As you know that CSV is…

How to convert CSV file to PDF file using iText API in Java

Here I am going to tell you how to convert CSV to PDF file using iText library in Java programming language. I am going to use Java 7 or later version’s new feature Path API to read the CSV file and Java 8’s Stream API to split the comma separated line or record. I am going to show you how…

Junit Testing for Multiple Files Upload Spring REST Controller

Introduction Here I am going to write Junit test case for testing multiple files upload in Spring REST Controller. I have already created how to upload multiple files using Spring REST API and I also had shown how to test it through REST client tool – Postman. In this tutorial I am going to use Junit 5, @WebMvcTest annotation to…

Java Junit 5 Mockito doNothing() Example

In this tutorial I am going to show you how to work with Mockito‘s doNothing() in Java Junit 5 API. Mockito‘s doNothing() or Mockito itself is widely used testing framework. If you are working with Junit 4 then you can read the similar example Mockito’s doNothing() using Junit 4. Mockito‘s doNothing() is used when you want to test void methods…

How to post image tweets to Twitter using Twitter4j Java API

In this example I am going to discuss on how to post image tweets to Twitter using Twitter4j Java API. Twitter4j is an unofficial Java library and using this you can easily integrate Java application with Twitter service. Using image tweets I want to mean that I want to post text as well as image with this tweet. As many…

How to select single or multiple records using JDBC executeQuery() and executeQueryForList()

Here we will discuss how to select single or multiple records using JDBC API. To select single record from database we use executeQuery() and to select multiple records we use executeQueryForList(). You may need to use executeQuery() to fetch single record from the database for various reasons, such as: You want to see details for a particular record You want…

Batch insert and batch update into DataBase using JDBC PreparedStatement

Introduction Here I am going to tell you how to insert and update a list of objects in batch using JDBC PreparedStatement in Java programming language. Generally when you have a list of objects or lots of data then probably it is not a good idea to insert or update individual record or object into database, because it makes lots…

How To Add Comments In Excel Sheet Cell Using Apache POI Java API

Introduction In an excel file, you might have seen there are comments on text cells or columns. So in this tutorial you will see how to add or insert comments in excel sheet cell using Apache POI Java API. Comments can help you to remember what all are formulae or instructions you want to provide to other excel users. In…

Should we synchronize run() method?

Here in this tutorial we will discuss whether we should synchronize the run() method or not. Another question may arise can we synchronize run() method? In simple word, yes, we can synchronize the run() method. Do we need to synchronize the run method? When it comes to whether we need to synchronize or not, then it is not necessary to…