How to read XML using SAX parser

How to read XML using SAX parser

In the previous article we talked about DOM parser and provided different examples for parsing and reading elements of an XML document. SAX parser is yet another XML parser provided...

How to create XML file in Java

How to create XML file in Java

In this tutorial, we show how to create a new XML file using DOM parser provided by JDK. We’re going to create an XML called students.xml which lists students along...

How to read XML file in Java

How to read XML file in Java

In this tutorial, we show how to read and parse an XML file using DOM parser provided by JDK. If you’re interested in SAX or STAX parser, please refer to these tutorials: SAX parser, STAX...

ClassNotFoundException vs NoClassDefFoundError

ClassNotFoundException vs NoClassDefFoundError

ClassNotFoundException and NoClassDefFoundError occur when a required class is not found in the classpath at runtime. In this tutorial, we resolve the conflict between these 2 exceptions and explain the different...

How to iterate a Map in Java

How to iterate a Map in Java

This tutorial shows several ways for iterating a Map in Java. 1- Entry Set The common way for iterating a Map in Java is through entrySet() method as the following:...

How to iterate a List in Java

How to iterate a List in Java

This tutorial shows several ways for iterating a List in Java. 1- Typical For loop Using a typical For loop, you can iterate a List as the following:

2-...

ArrayList vs Vector

ArrayList vs Vector

ArrayList and Vector collections are used interchangeably for storing several items with the same type inside the memory. In this tutorial, we list the major similarities and differences between these 2...

Hashtable VS HashMap

Hashtable VS HashMap

Hashing objects like HashMap and Hashtable are mostly used for storing and caching data as a key/value pairs inside the memory. In this tutorial, we list the major similarities and...

Java – Convert File to byte[]

Java – Convert File to byte[]

This tutorial shows several ways to convert a File object to a byte[] array in Java. 1- Traditional way The traditional conversion way is through using read() method of InputStream as...

Java – Convert byte[] to File

Java – Convert byte[] to File

This tutorial shows several ways to convert a byte[] array to File in Java. 1- Traditional way The traditional way of doing the conversion is through using FileOutputStream as the...

Convert JSON to Java Object

Convert JSON to Java Object

This tutorials shows 2 ways for converting a JSON string to a Java object. 1- Gson Gson is the most popular library for converting JSON string to Java objects. With Gson, you...

Convert Java object to JSON

Convert Java object to JSON

This tutorial shows 2 ways for converting Java objects to JSON. This kind of conversion is normally done via third-party libraries as it’s not supported by the JDK itself and...

Java - Convert InputStream to String

Java – Convert InputStream to String

This tutorial shows several ways to convert an InputStream to a String in Java. 1- BufferedReader The common way for generating a String out of an InputStream is through using...

Java - Convert InputStream to File

Java – Convert InputStream to File

This tutorial shows several ways to convert InputStream to File in Java. 1- Common way The common way for converting InputStream to File is through using OutputStream. You can’t directly...

Java - Convert List to Array

Java – Convert List to Array

This tutorial shows several ways to convert a List to Array in Java. 1- toArray() List provides a utility method called toArray() which accepts an empty array and populates it...