APACHE COMMONS / CATATAN</>↗Apache Commons14 Jul 2007
In the code example below we demonstrate the ArrayUtils.toPrimitive() method to convert an array of Integer object to an array of its primitive type. Besides converting an array of Integer objects, this method is overloaded to accept other types of object’s array. package org.kodejava.commons.lang; import org.apache.commons.lang3.ArrayUtils; public class ArrayObjectToPrimitiveDemo { public static void main(String[] args) […]
APACHE COMMONS / CATATAN</>↗Apache Commons11 Jul 2007
This example uses the Apache Commons Lang’s ArrayUtils.toMap() method to convert a two-dimensional array into a Map object. To convert a two-dimensional array into a Map object, each element of the two-dimensional array must be an array with at least two elements where the first element will be the key and the second element will […]
APACHE COMMONS / CATATAN</>↗Apache Commons09 Jul 2007
In this example we are going to use the ArraysUtils helper class from the Apache Commons Lang library to reverse the order of array elements. The method to reverse the order of array elements is ArrayUtils.reverse() method. The ArrayUtils.reverse() method is overloaded, so we can reverse another type of array such as java.lang.Object, long, int, […]
APACHE COMMONS / CATATAN</>↗Apache Commons28 Agt 2006
This example shows how we can use the Apache Commons IO library to simplify a file copy process. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; public class FileCopyExample { public static void main(String[] args) { // The source file name to be copied. File source = new File("README.md"); // The target file name to […]
APACHE COMMONS / CATATAN</>↗Apache Commons13 Agt 2006
package org.kodejava.commons.lang; import org.apache.commons.lang3.StringUtils; public class WordCountDemo { public static void main(String[] args) { // We have the source text we'll do the search on. String source = "From the download page, you can download the Java " + "Tutorials for browsing offline. Or you can just download " + "the example."; // The word […]
APACHE COMMONS / CATATAN</>↗Apache Commons09 Agt 2006
package org.kodejava.commons.lang; import org.apache.commons.lang3.StringUtils; public class StringReverseDemo { public static void main(String[] args) { // We have an original string here that we'll need to reverse. String words = "The quick brown fox jumps over the lazy dog"; // Using StringUtils.reverse we can reverse the string letter by letter. String reversed = StringUtils.reverse(words); // Now […]