User Defined Exceptions in Java

While working on an application, you may come across some scenarios where you feel like the Exceptions defined in the java platform are not enough to represent the error/issue you want to tell the end user. In that case you may choose

Read More

Sorting TreeMap Using Comparator

TreeMap are sorted naturally using their Keys. If you have your objects as keys then Sorting TreeMap using Comparator is a good way to decide the map order. Lets see an example on how to use Comparator in a TreeMap 1. User

Read More

WeakHashMap example in Java

WeakHashMap is a HashTable based implementation of the Map Interface. The keys of the WeakHashMap have weak reference and so an entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. Each key object in

Read More

LinkedHashMap example in Java

LinkedHashMap is part of the java.util package and it extends the HashMap, so it has all the properties of HashMap. LinkedHashMap maintains the order of insertion of the elements, hence when we iterate a LinkedHashMap we get the elements in the order

Read More

TreeMap example in Java

TreeMap is a part of the java.util package and implements the Map interface. TreeMap stores the Key-Value pairs in a sorted order of the Keys. TreeMap is a Red-Black tree based NavigableMap implementation. Red-Black Tree – Ref- wiki A red–black tree is

Read More

Read Word Docx File Using POI

To read word docx file using POI we use the XWPFWordExtractor class. This class comes from the package org.apache.poi.xwpf.extractor and has a method getText() that returns all the content of the file in simple String. We will examples of the XWPFWordExtractor with

Read More

Add Table to Word Doc using POI

In many cases we need to deal with tables in the Word Document. Apache POI makes it simple to add table to the Word Document. Lets see the way to add table to word doc using POI. Classes / Interfaces Used XWPFTable

Read More

Add Border to Paragraph in Word Using POI

We have already see the creation of Word file and adding Paragraph to it using Apache POI. Now we will see how to add Border to Paragraph in Word using POI. Classes / Interfaces Used XWPFDocument [crayon-5ad938bac62c8407099031-i/] is used to create the

Read More

Add Paragraph to Word Doc Using POI

In the last post we saw how to Create Word Doc file in Java Using POI. Now in this post we will see how to add Paragraph to Word doc using POI. Classes / Interfaces Used XWPFDocument [crayon-5ad938bac6810279138394-i/] is used to create

Read More

Create Word Doc file in Java Using POI

Apache POI is very useful for working on with the MS office files like Word, Excel etc. In the post we will how to create word doc file in java using POI. Setup for Apache POI [crayon-5ad938bac6d2b900675452/] NOTE : For non maven

Read More