SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

CORE API / NOTES</>↗
Core API01 Sep 2006

How do I get operating system temporary directory / folder?

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"; […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons28 Aug 2006

How do I create a copy of a file?

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 […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API26 Aug 2006

How do I convert day-of-year to day-of-month?

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: " […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API22 Aug 2006

How do I check if a year is a leap year?

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 […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API18 Aug 2006

How do I calculate difference in days between two dates?

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 […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons13 Aug 2006

How do I count word occurrences in a string?

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 […]

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.