APACHE POI / NOTES</>↗Apache POI15 Dec 2008
This example demonstrate how to create an Excel document using Apache POI library. In this example we create a simple document containing two sheets which have a value on their first cell. package org.kodejava.poi; import org.apache.poi.hssf.usermodel.*; import java.io.FileOutputStream; import java.io.IOException; public class CreateExcelDemo { public static void main(String[] args) { // Creating an instance of […]
ITEXT PDF / NOTES</>↗iText PDF14 Dec 2008
This example is the first example of the iText PDF series, we are going to start by learning to use the iText PDF library to create a PDF document. We will see how to use the Document class, getting an instance of PdfWriter, creating a simple Paragraph and set the text alignment and the font. […]
CORE API / NOTES</>↗Core API11 Dec 2008
The code below detect if a given string has a non ASCII characters in it. We use the CharsetDecoder class from the java.nio package to decode string to be a valid US-ASCII charset. package org.kodejava.io; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharacterCodingException; import java.nio.CharBuffer; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Arrays; public class NonAsciiValidation { public static void main(Str...
HIBERNATE / NOTES</>↗Hibernate09 Dec 2008
This example demonstrate the use of Hibernate’s Restriction.in criterion. This restriction will query for some record based on a collection of parameter defined for a specific property of the bean. package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; import org.hibernate.HibernateException; import org.hibernate.Criteria; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Restrictions; import org.kodejava.hibern...
CORE API / NOTES</>↗Core API07 Dec 2008
A temporary file can be created by using java.io.File.createTempFile() method. It accepts the prefix, suffix and the path where the file will be stored. When no path is specified it will use the platform default temporary folder. The name of the temporary file will be in the form of prefix plus five or more random […]
CORE API / NOTES</>↗Core API05 Dec 2008
This example shows you how to add or subtract hours, minutes or seconds to a date using the java.util.Calendar object. package org.kodejava.util; import java.util.Calendar; public class DateAddSubtract { public static void main(String[] args) { // Gets a calendar using the default time zone and locale. The // Calendar returned is based on the current time […]