How to read a plain text file in Java

How to read a plain text file in Java

This tutorial shows several ways for reading plain text files in Java. The techniques we use here are totally JDK built-in and don’t depend on external libraries. 1- BufferedReader The...

How to read input from console in Java

How to read input from console in Java

This tutorial shows several ways for reading input from a console in Java. Before listing the ways, it’s worth to define System.in as it’s used by most reading ways. System.in...

How to modify XML using DOM in Java

How to modify XML using DOM in Java

Although the main purpose of XML documents is to store lightweight data for faster processing, they are still used in some small applications as a data store which requires dynamic...

How to read XML using STAX parser

How to read XML using STAX parser

STAX is yet another parser for reading and parsing XML documents in Java, it is very similar to SAX where they both parse the XML document on call and provide...

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:...