CORE API / NOTES</>↗Core API13 Sep 2008
In this program we read the file contents byte by byte and then print the value in hexadecimal format. As an alternative to read a single byte we can read the file contents into array of bytes at once to process the file faster. package org.kodejava.io; import java.io.FileInputStream; public class HexDumpDemo { public static void […]
SWING / NOTES</>↗Swing11 Sep 2008
This demo gives examples of using the SwingWorker class. The purpose of SwingWorker is to implement a background thread that you can use to perform time-consuming operations without affecting the performance of your program’s GUI. package org.kodejava.swing; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.WindowConstants; import java.awt.Dimension; impo...
CORE API / NOTES</>↗Core API11 Sep 2008
This example demonstrate Date‘s class after() method to check if a date is later than another date. package org.kodejava.util; import java.util.Date; import java.util.Calendar; public class DateCompareAfter { public static void main(String[] args) { // Get current date Date today = new Date(); // Add 1 day from the current date. Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, […]
CORE API / NOTES</>↗Core API10 Sep 2008
This example demonstrate Date‘s class before() method to check if a date is earlier than another date. package org.kodejava.util; import java.util.Date; import java.util.Calendar; public class DateCompareBefore { public static void main(String[] args) { // Get current date Date today = new Date(); // Subtract 1 day from the current date. Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, […]
BASIC / NOTES</>↗Basic10 Sep 2008
An inner class is a class defined inside another class. Inner classes can, in fact, be constructed in several contexts. An inner class defined as a member of a class can be instantiated anywhere in that class. An inner class defined inside a method can only be referred to later in the same method. Inner […]
BASIC / NOTES</>↗Basic06 Sep 2008
To enable our object to be cloned we need to override Object class clone method. We can also add a java.lang.Cloneable interface to our class, this interface is an empty interface. When we call the clone() method we need the add a try-catch block to catch the CloneNotSupportedException. This exception will be thrown if we […]