APACHE COMMONS / NOTES</>↗Apache Commons01 Sep 2008
package org.kodejava.commons.codec; import org.apache.commons.codec.binary.Base64; import java.util.Arrays; public class Base64Decode { public static void main(String[] args) { String hello = "SGVsbG8gV29ybGQ="; // Decode a previously encoded string using decodeBase64 method and // passing the byte[] of the encoded string. byte[] decoded = Base64.decodeBase64(hello.getBytes()); // Print the decoded array System.out.println(Arrays.toString(decoded)); // Convert the decoded byt...
APACHE COMMONS / NOTES</>↗Apache Commons28 Aug 2008
package org.kodejava.commons.codec; import org.apache.commons.codec.binary.Base64; import java.util.Arrays; public class Base64Encode { public static void main(String[] args) { String hello = "Hello World"; // The encodeBase64 method take a byte[] as the parameter. The byte[] // can be from a simple string like in this example, or it can be from // an image file data. byte[] […]
CORE API / NOTES</>↗Core API24 Aug 2008
package org.kodejava.util; import java.util.*; public class SetToArray { public static void main(String[] args) { // Create a java.util.Set object and add some integers into the Set. Set<Integer> numberSet = new HashSet<>(); numberSet.add(1); numberSet.add(2); numberSet.add(3); numberSet.add(5); numberSet.add(8); // Converting a java.util.Set into an array can be done by creating a // java.util.List object from the Set […]
CORE API / NOTES</>↗Core API23 Aug 2008
The code below gives you an example of converting a java.util.Set into a java.util.List. It has simply done by creating a new instance of List and pass the Set as the argument of the constructor. package org.kodejava.util; import java.util.*; public class SetToList { public static void main(String[] args) { // Create a Set and add […]
CORE API / NOTES</>↗Core API20 Aug 2008
package org.kodejava.util; import java.util.Properties; import java.util.Map; import java.util.HashMap; import java.util.Set; public class PropertiesToMap { public static void main(String[] args) { // Create a new instance of Properties. Properties properties = new Properties(); // Populate properties with a dummy application information properties.setProperty("app.name", "HTML Designer"); properties.setProperty("app.version", "1.0"); properties.setProperty("app.vendor", "HTM...
APACHE COMMONS / NOTES</>↗Apache Commons16 Aug 2008
This example demonstrates how to use Apache Commons IO LastModifiedFileComparator class to sort files based on their last modified date in ascending and descending order. There are two comparators defined in this class, the LASTMODIFIED_COMPARATOR and the LASTMODIFIED_REVERSE. package org.kodejava.commons.io; import static org.apache.commons.io.comparator.LastModifiedFileComparator.*; import java.io.File; import java.util.Arrays; public class FileSortLastModified { public sta...