Reading a .gz File Line by Line Using GZIPInputStream
1. Overview We may wish to work with compressed files in Java. A common format is .gz, as generated by the GZIP utility. Java has a built-in library for reading .gz files, which are commonly used for...
View ArticleNormalizing the EOL Character in Java
1. Introduction Different operating systems use different end-of-line (EOL) characters, which might lead to problems when files are transferred or processed between systems. Besides, normalizing EOL...
View ArticleConverting UTF-8 to ISO-8859-1 in Java
1. Introduction The issue of character encoding is of vital importance for Java programming when working with several systems and data sources. In this tutorial, we’ll discuss how to convert UTF-8...
View ArticleWhen to Use Setter Methods or Constructors for Setting a Variable’s Value in...
1. Introduction One of the choices that developers encounter is whether setter methods or constructors should be used to set the value of a variable. Both techniques have their benefits, however they...
View ArticleGet List of Entity From Database in Hibernate
1. Introduction Hibernate is a powerful ORM (Object-Relational Mapping) framework that simplifies the interaction between Java objects and relational databases. Hibernate abstracts away the...
View ArticleJava InputStream vs. InputStreamReader
1. Overview In this article, we’ll discuss the InputStream class and how it can handle binary information from various sources. We’ll also discuss the InputStreamReader class and its differences...
View ArticleCreate Spring Prototype Scope Bean with Runtime Arguments
1. Overview In this quick article, we’re going to learn about creating a prototype-scoped bean with runtime arguments in Spring. In Spring, there are many different bean scopes, but the default scope...
View ArticleSaga Pattern in Microservices Architecture
1. Introduction In a typical microservice-based architecture, where a single business use case spans multiple microservices, each service has its own local datastore and localized transaction. When it...
View ArticleFix Ambiguous Method Call Error in Mockito
1. Overview In this tutorial, we’ll see how to avoid ambiguous method calls in the specific context of the Mockito framework. In Java, method overloading allows a class to have multiple methods with...
View ArticleInclude null Value in JSON Serialization
1. Introduction When we work with Java objects and need to convert them into JSON format, it’s crucial to handle null values appropriately. Omitting null values from the JSON output might not align...
View Article@Subselect Annotation in Hibernate
1. Introduction In this tutorial, we’ll review the @Subselet annotation in Hibernate, how to use it, and its benefits. We’ll also see Hibernate’s constraints on entities annotated as @Subselect and...
View ArticleJava Weekly, Issue 535 – Out with the RestTemplate (again)
1. Spring and Java >> Java 22 Delivers Foreign Memory & Memory API, Unnamed Variables & Patterns, and Return of JavaOne [infoq.com] Last week, we celebrated the release of Java 22, but...
View ArticleFind Map Keys with Duplicate Values in Java
1. Overview Map is an efficient structure for key-value storage and retrieval. In this tutorial, we’ll explore different approaches to finding map keys with duplicate values in a Set. In other words,...
View ArticleMerge Overlapping Intervals in a Java Collection
1. Overview In this tutorial, we’ll look at taking a Collection of intervals and merging any that overlap. 2. Understanding the Problem First, let’s define what an interval is. We’ll describe it as a...
View ArticleFinding Element by Attribute in Selenium
1. Introduction Selenium offers plenty of methods to locate elements on a webpage, and we often need to find an element based on its attribute. Attributes are additional pieces of information that can...
View ArticleThe @Struct Annotation Type in Hibernate – Structured User-Defined Types
1. Overview In this tutorial, we’ll review Hibernate’s @Struct annotation which let’s developers create structured user-defined types. Support for structured user-defined types, a.k.a structured types,...
View ArticleGet Last n Characters From a String
1. Overview In this tutorial, we’ll explore a few different ways to get the last n characters from a String. Let’s pretend that we have the following String whose value represents a date: String s =...
View ArticleLogging in Spring Boot With Loki
1. Introduction Grafana Labs developed Loki, an open-source log aggregation system inspired by Prometheus. Its purpose is to store and index log data, facilitating efficient querying and analysis of...
View ArticleCheck if an Element Is Present in a Set in Java
1. Overview In this short tutorial, we’ll cast light on how to check if an element is present in a Set in Java. First, we’ll kick things off by exploring solutions using core JDK. Then, we’ll elucidate...
View Article