JDOM Example : Reading and Parsing XML with SAX parser in Java

XML parsing with JDOM parser

How to Search Element in Java Array with Example

find an index of the object in Array

Difference between Serializable vs Externalizable in Java - Interview Question

Serializable vs Externalizable

How to iterate over HashSet in Java - loop or traverse Example

Iterating over HashSet in Java
Java program to Iterate over HashSet in Java with ExampleIn our last Java collection tutorial, we have seen How to iterate over ArrayList in Java and in this tutorial we will see How to iterate over HashSet in Java. There are two ways to iterate, loop or traverse over HashSet in Java, first using advanced for-each loop added on Java 5 and second using Iterator which is a more conventional way of iterating over HashSet in Java. Now questions are When should you use for loop and when Iterator is an appropriate option. Well I usually use for loop If I only read from HashSet and doesn't remove any element, while Iterator is preferred approach. You should not remove elements from HashSet while iterating over it in for loop, Use Iterator to do that.

How to convert Hexadecimal to Decimal, Binary and Octal in Java program - Example

Hexadecimal to decimal and binary conversion in Java
This Java program will convert Hexadecimal number to decimal, binary and Octal in Java programming language using JDK standard API methods. For beginners hexadecimal is base 16 number, while decimal is base 10, Octal is base 8, and binary is base 2 numbers in Number systems. Binary only contains 0 and 1 bits, octal contains 0 to 7, decimal contains 0 to 9 and Hexadecimal contains 0-9,A,B,C,D,E,F where F represent 15. Thankfully Java library provides a convenient method to convert any integer from one number system to another. In our last article we have seen How to convert decimal numbers to binary in Java and in this article we will convert Hexadecimal numbers to binary, octal, and decimal numbers.

How to convert ArrayList to String in Java - Spring Example

Some time we need to convert ArrayList to String in Java programming language in order to pass that String to stored procedure, any method or any other program. Unfortunately Java collection framework doesn't provide any direct utility method to convert ArrayList to String in Java. But Spring framework which is famous for dependency Injection and its IOC container also provides API with common utilities like method to convert Collection to String in Java. You can convert ArrayList to String using Spring Framework's StringUtils class. StringUtils class provide three methods to convert any collection e.g. ArrayList to String in Java, as shown below:

20 EJB 3.0 Interview Questions and Answers - Java J2EE


Java Program to Read a File in Java - Windows UNIX Example

Java provides  package in JDK API for reading File in Java from File system e.g. C:\ or D:\ drive in Windows or any other directory in UNIX. First, you can use FileInputStream to open a file for reading. FileInputStream takes a String parameter which is a path for the file you want to read. Be careful while specifying File path as path separator is different on Window and UNIX. Windows uses back slash while UNIX uses forward slash as a path separator. By the way, Java supports forward slash in Windows, It means if use forward slash your program will work on both Windows and UNIX. Alternatively, you can also get PATH separator from System property path.separator. In this Java tutorial, we will code example of How to read File in Java.