Baeldung » Java
1,286 FOLLOWERS
Baeldung helps developers explore the Java ecosystem and simply be better engineers. Java is the popular programming language that originated in 1995. Today, the Java ecosystem includes a very large number of specifications, libraries, frameworks, tools, as well as a thriving community. Take a dive through our collection of Java tutorials that cover a wide array of Java-related topics.
Baeldung » Java
10h ago
Learn how to add elements from multiple String arrays to an ArrayList in Java.
  ..read more
Baeldung » Java
10h ago
Tutorial on how to add JAR files manually to a VSCode project.
  ..read more
Baeldung » Java
10h ago
Tutorial on the use and differences between the three Maven variables: M2_HOME, MAVEN_HOME, and PATH.
  ..read more
Baeldung » Java
10h ago
Scoped values, effective logging, numerous Spring updates, deprecated JFR event, and rate limiting in APISIX.
  ..read more
Baeldung » Java
20h ago
Learn how to convert between org.joda.time.DateTime and java.sql.Timestamp classes in Java.
  ..read more
Baeldung » Java
4d ago
1. Introduction
In this tutorial, we’ll explore how to convert a Gson JsonArray to a HashMap in Java. By the end of this tutorial, we’ll understand the process of iterating over a JsonArray, extracting its elements, and storing them in a HashMap.
2. Understanding Gson JsonArray and HashMap Structures
A Gson JsonArray is a part of the Gson library and we use it to represent an array of JSON elements. Here’s an example structure of a JsonArray:
[
{"name": "John Doe", "age": 35},
{"name": "Mary Jenn", "age": 41}
]
On the other hand, a HashMap is a collection that stores key-value pairs ..read more
Baeldung » Java
4d ago
1. Overview
When working with file uploads in Java, it’s crucial to ensure that the uploaded files are indeed images, especially when filenames and extensions can be misleading.
In this tutorial, we’ll explore two ways to determine whether a file is an image: Checking the file’s actual content and verifying based on the file’s extension.
2. Checking File Content
One of the most reliable ways to determine if a file is an image is by inspecting its content. Let’s explore two methods to do this: Using Apache Tika and then using the built-in Java ImageIO class.
2.1 Using Apache Tika
mimeApache Tik ..read more
Baeldung » Java
4d ago
1. Introduction
Java provides various ways to work with byte[] arrays, which are essential for handling binary data. While initializing a byte[] array with decimal values is straightforward, using hexadecimal notation can make the representation of binary data more intuitive and readable.
This article will explore how to use hex notation for initializing byte[] arrays in Java, highlighting its advantages and applications.
2. Understanding byte[] Arrays
In Java, a byte[] array is used to store a sequence of bytes. Each byte can hold an 8-bit signed value ranging from -128 to 127. Byte arrays ar ..read more
Baeldung » Java
5d ago
1. Overview
In this article, we’ll see the power of using Testcontainers to help test a Quarkus application using ‘live’ service-to-service testing.
Testing in a microservices architecture is important and it can be difficult to reproduce a production-like system. Common options to enable testing include using manual API testing tools such as Postman, mocking services, or trusting in-memory databases. We might not perform a real service-to-service interaction until running a CI pipeline or deploying to upper environments. This can pose a problem, and delay delivery, by not thoroughly testing s ..read more
Baeldung » Java
5d ago
1. Overview
JSON is a widely employed structured data format typically used in most modern APIs and data services. It’s particularly popular in web applications due to its lightweight nature and compatibility with JavaScript.
Sometimes, it may be useful to sort the data before we display it in applications that fetch JSON.
In this quick tutorial, we’ll see a couple of approaches for sorting JSON objects in Java.
2. Getting Started
Let’s get started by defining a relatively simple JSON structure which models some imaginary Solar Events:
{
"solar_events": [
{
"event_name ..read more