Aishwarya Naglot has Published 180 Articles

Importance of a JSONTokener in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 12-May-2025 11:03:10

2K+ Views

If you have ever worked with JSON in Java, you might have used classes like JSONObject, JSONArray, JsonParser, etc. These classes are part of the org.json library. We use these classes to build JSON or parse JSON. But behind the scenes, these classes use a class called JSONTokener. In this ... Read More

How to implement custom JSON serialization with Gson in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 12-May-2025 10:38:49

1K+ Views

Custom JSON serialization Custom JSON Serialization means defining how your Java objects should be converted to JSON format. This is useful when you want to control the JSON output, such as changing field names, excluding certain fields, or formatting the data in a specific way. In this tutorial, we will ... Read More

How to convert XML to JSON array in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 12-May-2025 10:31:12

9K+ Views

Xml is a markup language that is used to store or transport data. It uses tags to define the data. There are libraries also available for converting XML to JSON. Those are: org.json Jackson Gson Let's ... Read More

How to write a JSON string to file using the Gson library in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 12-May-2025 10:22:09

2K+ Views

Let's learn how to write a JSON string to a file using the Gson library in Java. If you are not familiar with JSON, you can refer to JSON Overview. Gson is a library that can be used to convert Java Objects to a JSON representation. To know more about ... Read More

How to implement custom JSON de-serialization with Gson in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 12-May-2025 10:12:16

669 Views

Deserialization is the process of converting JSON data back into Java objects. Gson provides a simple way to do this using the fromJson() method. Custom JSON de-serialization with Gson Gson is a Java library developed by Google to convert Java objects into their JSON format and vice versa. Custom JSON ... Read More

Java program to List all files in a directory recursively

Aishwarya Naglot

Aishwarya Naglot

Updated on 12-May-2025 10:04:59

5K+ Views

The given task is to list all the files from a specific directory, recursively, which means we need to retrieve all the files in the main directory and all the subdirectories as well. For example, if we have a directory structure like below - ... Read More

How to serialize and de-serialize generic types using the Gson library in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 12-May-2025 09:15:57

2K+ Views

If a Java class is a generic type, and we are using it with the Gson library for JSON serialization and deserialization, the TypeToken class from com.google.gson.reflect package is used for preserving the generic type information at runtime. What are Generic Types in Java? Generic types in Java mean we don't ... Read More

Java Stream findAny() Method with Examples

Aishwarya Naglot

Aishwarya Naglot

Updated on 09-May-2025 18:39:31

1K+ Views

In this article, we will learn the findAny() method with examples in Java. The findAny() method in Java Streams is a tool that is used for fetching an arbitrary element from a stream. It provides a quick and easy way to retrieve any element without writing any conditions. This method ... Read More

Java streams counting() method with examples

Aishwarya Naglot

Aishwarya Naglot

Updated on 08-May-2025 18:03:47

449 Views

In this article, we will learn how to count the number of elements in a stream using the counting() method in Java Streams. Java Streams provide an efficient way to process data collections, and the Collectors.counting() method is useful for counting the number of elements in a stream. The counting() ... Read More

Difference between ArrayList.clear() and ArrayList.removeAll() in java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 08-May-2025 11:56:44

1K+ Views

The ArrayList class in Java is a Resizable-array implementation of the List interface. It allows null values. Java clear() Method V/S removeAll() Method There are some important differences between the clear() and removeAll (Collection c) methods of the ArrayList class. This table compares these two methods. ... Read More

Advertisements