CORE API / NOTES</>↗Core API02 Aug 2008
This example demonstrate encrypting an object using DES algorithm. After the object was encrypted we store it in a file which will be decrypted in the next example here How do I decrypt an object with DES. package org.kodejava.crypto; import java.io.*; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SealedObject; import javax.crypto.SecretKey; public class ObjectEncrypt { public static […]
CORE API / NOTES</>↗Core API01 Aug 2008
This code checks a string to determine if it is a palindrome or not. A palindrome is a word, phrase, or sequence that reads the same backward as forward. package org.kodejava.lang; public class PalindromeChecker { public static void main(String[] args) { String text = "Sator Arepo Tenet Opera Rotas"; PalindromeChecker checker = new PalindromeChecker(); System.out.println("Is […]
CORE API / NOTES</>↗Core API29 Jul 2008
Here is the second way for creating a thread. We create an object that implements the java.lang.Runnable interface. For another example see How do I create a thread by extending Thread class?. package org.kodejava.lang; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class TimeThread implements Runnable { private final DateFormat df = new SimpleDateFormat("hh:mm:ss"); // The […]
CORE API / NOTES</>↗Core API28 Jul 2008
There are two ways that we can use tho create a thread. First is by extending the java.lang.Thread class and the second way is by creating a class that implements the java.lang.Runnable interface. See How do I create a thread by implementing Runnable interface? In this example we’ll extend the Thread class. To run a […]
CORE API / NOTES</>↗Core API23 Jul 2008
In this example you’ll see the utilization of SimpleDateFormat class for comparing two dates for equality. We convert the date object into string using the DateFormat instance and then compare it using String.equals() method. package org.kodejava.util; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class ComparingDate { public static void main(String[] args) { // […]
APACHE COMMONS / NOTES</>↗Apache Commons20 Jul 2008
This example demonstrates how we can use the FileUtils class listFiles() method to search for a file specified by their extensions. We can also define to find the file recursively deep down into the subdirectories. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.util.Collection; public class SearchFileRecursive { public static void main(String[] args) { File root […]