Get the Indices of an Array After Sorting in Java
1. Introduction Sorting an array is a common operation in Java, but sometimes, we also need to know the original indices of the elements after sorting. This information can be crucial for certain...
View ArticleHow to Convert XML to PDF
1. Overview Java provides several libraries and APIs for working with XML and PDF documents. Converting XML to PDF in Java involves parsing the XML data, applying styles and formatting, and generating...
View ArticleConvert Between CLOB and String in Java
1. Introduction When working with databases in Java, handling large text data is a common task. Besides, the Character Large Object (CLOB) type allows databases to store extensive text data. Moreover,...
View ArticleClear Managed Entities in JPA/Hibernate
1. Overview In this tutorial, we’ll review how entities are managed in JPA and then explore a scenario where the persistence context may not return fresh data due to external changes. 2. Persistence...
View ArticleMonitor a Spring Boot App Using Prometheus
1. Overview In the demanding world of software development, ensuring that applications perform optimally and reliably once deployed in production environments is not just preferable — it’s essential....
View ArticleUsing @Autowired and @InjectMocks in Spring Boot Tests
1. Overview In this tutorial, we’ll explore the usage of Spring Boot’s @Autowired and Mockito’s @InjectMocks while injecting dependencies in Spring Boot tests. We’ll go over the use cases that require...
View ArticleComparison Between Flux.map() and Flux.doOnNext()
1. Overview In the Reactor library, the Flux.map() and Flux.doOnNext() operators play different roles in working with stream data elements. The Flux.map() operator helps to transform each element...
View ArticleMerge Multiple PDF Files Into a Single PDF Using Java
1. Introduction In the modern business and document management workflow, the ability to merge multiple PDF files into a single PDF document is a common requirement. Common use cases include...
View ArticleMap LocalDateTime to Instant in MapStruct
1. Overview When working with dates and times in Java, we often encounter different formats, such as LocalDateTime and Instant. While LocalDateTime represents a date-time without a time zone, Instant...
View ArticleSolving Spring Data JPA ConverterNotFoundException: No converter found
1. Overview When using Spring Data JPA, we often leverage derived and custom queries that return the result in our preferred formats. A typical example is the DTO projection, which offers a great way...
View ArticleReturn Non-null Elements From Java 8 Map Operation
1. Overview The Java Stream API introduced many features that significantly enhance the functionality and readability of our code. Among these, the map() method stands out as a powerful tool for...
View ArticleDeclare an Enum in an Inner Class in Java
1. Introduction When working with Java, enums serve as a convenient way to define a fixed set of constants. However, creating enums within inner classes can introduce some complexities and...
View ArticleConvert Decimal to Fraction in Java
1. Introduction A fraction is another way of representing a number, consisting of a numerator and a denominator. For example, the fraction 3/5 can be thought of as “3 out of 5,” representing the same...
View ArticleUsing Comparator.nullsLast() to Avoid NullPointerException When Sorting
1. Overview Sorting a collection that contains null values can lead to a NullPointerException if not handled properly. Java 8 has a convenient method Comparator.nullsLast() to address this issue. This...
View ArticleCompletableFuture vs. Mono
1. Overview In this quick tutorial, we’ll learn the differences between CompletableFuture and Mono from Project Reactor in Java. We’ll focus on how they handle asynchronous tasks and the execution that...
View ArticleStatic Code Analysis Using Infer
1. Introduction In the realm of software development, ensuring code quality is very important, especially for complex and large codebases. Static code analysis tools like Infer provide us with...
View ArticleReplacing Strings in Java Using Regex: Back Reference vs. Lookaround
1. Overview In this tutorial, we’ll examine how to use the replaceAll() provided in the String class to replace text using regular expressions. Additionally, we’ll learn two methods, back reference and...
View ArticleJava Weekly, Issue 543
1. Spring and Java >> JEP 467: Java Enhances Documentation with Markdown Support [infoq.com] Another look at the proposed feature for Java 23: enabling markdowns in JavaDocs, instead of a painful...
View ArticleOpenAI API Client in Java
1. Overview With the widespread use of generative AI and ChatGPT, in particular, many languages have started to provide libraries that interact with their OpenAI API. Java isn’t an exception. In this...
View ArticleConsumer Processing of Kafka Messages With Delay
1. Overview Apache Kafka is an event streaming platform that collects, processes, stores, and integrates data at scale. Sometimes, we may want to delay the processing of messages from Kafka. An example...
View Article