CORE API / NOTES</>↗Core API28 Apr 2008
This example demonstrates how to copy file using the Java IO library. Here we will use the java.io.FileInputStream and it’s tandem the java.io.FileOutputStream class. package org.kodejava.io; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class FileCopyDemo { public static void main(String[] args) { // Create an instance of source and destination files File source […]
CORE API / NOTES</>↗Core API24 Apr 2008
The System.clearProperty(String key) method enables you to remove a system property. The key must not be an empty string or a null value because it will cause the method to throw an IllegalArgumentException or a NullPointerException. It will also check if a SecurityManager exists and if you don’t have a write permission to the system […]
SWING / NOTES</>↗Swing20 Apr 2008
This example show you how to handle JFrame window events such as windowOpened, windowClosing, windowClosed, etc. For handling these events we need to add a WindowListener listener to the JFrame instance. Here we use the WindowAdapter abstract class and implement the method which event we want to handle. package org.kodejava.swing; import javax.swing.JFrame; import javax.swing.SwingUtilities; import […]
CORE API / NOTES</>↗Core API15 Apr 2008
Creating a program to be run on more than one platform such as Windows and Linux our program need to understand the difference between both platform. The simplest thing for instance is the file separator. Windows use "\" (backslash) while Linux use "/" (forward slash). To avoid manual checking for the operating system we can […]
CORE API / NOTES</>↗Core API15 Apr 2008
This example shows how we can change the date formatting symbols. In this example we change the month names and short month names and also the weekday names and short weekday names. Other than these two items we can also change other symbols such as the Era name and AM-PM string. package org.kodejava.text; import java.text.SimpleDateFormat; […]
BASIC / NOTES</>↗Basic15 Apr 2008
package org.kodejava.lang; public class XorDemo { public static void main(String[] args) { int numberA = 16; int numberB = 32; // Operator ^ is used for doing bitwise exclusive OR operation int result = numberA ^ numberB; System.out.println(numberA + " ^ " + numberB + " = " + result); // Print the result in […]