CORE API / NOTES</>↗Core API01 Sep 2006
To get the location of temporary directory we can use the System.getProperty(String) method and pass a property key "java.io.tmpdir" as the argument to the method. package org.kodejava.lang; public class TempDirExample { public static void main(String[] args) { // This is the property name for accessing OS temporary directory // or folder. String property = "java.io.tmpdir"; […]
APACHE COMMONS / NOTES</>↗Apache Commons28 Aug 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 […]
CORE API / NOTES</>↗Core API26 Aug 2006
package org.kodejava.util; import java.util.Calendar; public class DayYearToDayMonth { public static void main(String[] args) { // Create an instance of calendar for the year 2017 and set the // day to the 180 day of the year. Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2021); cal.set(Calendar.DAY_OF_YEAR, 180); // Print the date of the calendar. System.out.println("Calendar date is: " […]
CORE API / NOTES</>↗Core API22 Aug 2006
The following example using the GregorianCalendar.isLeapYear() method to check if the specified year is a leap year. package org.kodejava.util; import java.util.GregorianCalendar; public class LeapYearExample { public static void main(String[] args) { // Here we show how to know if a specified year is a leap year or // not. The GregorianCalendar object provide a convenient […]
CORE API / NOTES</>↗Core API18 Aug 2006
In the following example we are going to calculate the differences between two dates. First, we will need to convert the date into the corresponding value in milliseconds and then do the math, so we can get the difference in days, hours, minutes, etc. For example to get the difference in day we will need […]
APACHE COMMONS / NOTES</>↗Apache Commons13 Aug 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 […]