iText – Read and Write PDF in Java

This article talks about reading and writing PDF using iText PDF library. pom.xml <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.10</version> </dependency> P.S Tested with iTextPdf 5.5.10 1. iText – Write PDF iText PdfWriter example to write content to a PDF file. PdfWriteExample.java package com.mkyong; import com.itextpdf.text.*; import com.itextpdf.text.pdf.PdfWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class …

Read more

Java Static keyword example

The static keyword in Java is a modifier used to create memory efficient code. It helps in managing the memory occupied by objects, variables and method definitions. The static keyword makes sure that there is only one instance of the concerned method, object or variable created in memory. It is used when one needs to …

Read more

Java – ResourceBundle example

The java.util.ResourceBundle is a library used for internationalization (multiple languages). It is able to return messages as per the default Locale configured for the system. Such a functionality is used when one develops systems to be used all over the world. 1. How it works? The library reads a property file based on the locale and name …

Read more

Java Final keyword example

Final keyword in Java is a modifier used to restrict the user from doing unwanted code or preventing from the code or value from being changed. It is possible to use this keyword in 3 contexts. They are: Final keyword as a variable modifier Final keyword as a method modifier Final keyword as a class …

Read more

How to read and write Java object to a file

Java object Serialization is an API provided by Java Library stack as a means to serialize Java objects. Serialization is a process to convert objects into a writable byte stream. Once converted into a byte-stream, these objects can be written to a file. The reverse process of this is called de-serialization. A Java object is …

Read more

Java AWT Layouts

The java.awt library provides 5 basic layouts. Each layout has its own significance and all of them are completely different. Here in this article, we will discuss how to apply any layout to a frame or a panel and also discuss about each layout in brief. The 5 layouts available in the java.awt library are: …

Read more

Java AWT – Drawing rectangle, line and circle

The java.awt libraries are set of classes provided by Java in order to draw shapes on a window. The abbreviation AWT stands for Abstract Windowing Toolkit. Today, the library has been converted into a huge set of classes which allows the user to create an entire GUI based application. The visual appearance of these classes …

Read more

Java – String vs StringBuffer

This article shows the difference in time taken for similar operations on a String object and StringBuffer object. String being an immutable class, it instantiates a new object each time an operation is performed on it StringBuffer being a mutable class, the overhead of object instantiation during operations is removed. Hence, the time taken for …

Read more