Compress and Create a Byte Array Using GZip
1. Overview The GZIP format is a file format used in data compression. The GZipInputStream and GZipOutputStream classes of the Java language implement this file format. In this tutorial, we’ll learn...
View ArticleImplement Update-Or-Insert in Spring Data JPA
1. Introduction In application development, the need to perform an update-or-insert operation, also known as “upsert”, is quite common. This operation involves putting a new record into a database...
View ArticleDifference Between Casting to String and String.valueOf()
1. Overview Manipulating Strings is a fundamental task when we work with Java. We often need to convert other data types into Strings. Two common approaches for accomplishing this are casting to String...
View ArticleImplement the Builder Pattern in Java 8
1. Introduction In our journey through software development, we often encounter scenarios where creating objects with numerous properties becomes intimidating. Cluttering our constructors is making our...
View ArticleConvert String to OffsetDateTime
1. Introduction Dealing with date and time values is a common task in software development, especially when building applications that involve scheduling, logging, or any time-sensitive operations. In...
View ArticlePersistenceUnit vs. PersistenceContext
1. Overview Persistence context and persistence unit are two important concepts in JPA that we use to manage the lifecycle of entities in an application. In this tutorial, we’ll take a look at a brief...
View ArticleCalculating Moving Averages in Java
1. Overview Moving averages are a fundamental tool in analyzing trends and patterns in data and are widely used in finance, economics, and engineering. They help smooth out short-term fluctuations and...
View ArticleJava Weekly, Issue 539
1. Spring and Java >> A preview of Jakarta Data 1.0 (Part II) [in.relation.to] Another new persistence specification for Java: exploring some dynamic features of Jakarta Data like static...
View ArticleFinding the nth Last Occurrence of char in String
1. Introduction In various text processing tasks, it’s common to encounter scenarios where we need to find the nth last occurrence of a specific character within a given string. Moreover, this...
View ArticleBigDecimal equals() vs. compareTo()
1. Overview Correctly handling numbers is crucial to any programming language. However, some applications rely more on the exact values and require a better representation of decimal numbers. For...
View ArticleUnit Test for hashCode() in Java
1. Introduction In Java, we can use the hashCode() method to generate a hash code value for an object. This value is typically used for various purposes, such as storing objects in collections like...
View ArticleRole-Based Access Control in Quarkus
1. Overview In this tutorial, we’ll discuss Role-Based Access Control (RBAC) and how we can implement this functionality using Quarkus. RBAC is a well-known mechanism for implementing a complex...
View ArticleContinue the Test Even After Assertion Failure in TestNG
1. Overview TestNG is a popular Java testing framework that’s an alternative to JUnit. While both frameworks offer their own paradigms, they both include the idea of assertions: logical statements that...
View ArticleGet 2’s Complement of a Number in Java
1. Introduction Two’s complement is a fundamental concept in computer science, particularly when dealing with signed binary numbers. It enables the representation of both positive and negative integers...
View ArticleCreate HashMap with Character Count of a String in Java
1. Introduction Handling character counts within a string is common in various programming scenarios. One efficient approach is to utilize a HashMap to store the frequency of each character in the...
View ArticleSetting Default TimeZone in Spring Boot Application
1. Overview Sometimes, we want to be able to specify the TimeZone used by an application. For a service running globally, this could mean that all servers are posting events using the same TimeZone, no...
View ArticleGet Nextval From Sequence With Spring JPA
1. Introduction Sequences are number generators for unique IDs to avoid duplicate entries in a database. Spring JPA offers ways to work with sequences automatically for most situations. However, there...
View ArticleIntro to Apache Commons Configuration Project
1. Overview At deployment time we may need to provide some configuration to the application. This can be from multiple external sources. Apache Commons Configuration provides a unified approach to...
View ArticleResolving Security Exception: java.security.UnrecoverableKeyException: Cannot...
1. Introduction In this tutorial, we’ll examine how to deal with java.security.UnrecoverableKeyException. We’ll also explore the details of what this exception actually means and what causes it....
View ArticleSpring WebClient exchange() vs retrieve()
1. Overview WebClient is an interface that simplifies the process of performing HTTP requests. Unlike RestTemplate, it’s a reactive and non-blocking client that can consume and manipulate HTTP...
View Article