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.

APACHE COMMONS / NOTES</>↗
Apache Commons22 May 2006

How do I implement equals() method using EqualsBuilder class?

This code snippet show you how to use HashCodeBuilder and EqualsBuilder class from the Apache Commons Lang library to implement the hashCode() and equals() method of an object. To use both of these classes, we just need to create instance of these classes and append the properties that we will use to calculate the hashcode […]

Wayan · 3 min read
APACHE COMMONS / NOTES</>↗
Apache Commons17 May 2006

How do I implement hashCode() method using HashCodeBuilder class?

package org.kodejava.commons.lang; public class ObjectHashCodeDemo { public static void main(String[] args) { Book book1 = new Book(1L, "Spring Boot in Action", "Craig Walls"); Book book2 = new Book(2L, "Docker in Action", "Jeff Nickoloff"); Book book3 = book1; System.out.println("book1.hashCode() = " + book1.hashCode()); System.out.println("book2.hashCode() = " + book2.hashCode()); System.out.println("book3.hashCode() = " + book3.hashCode()); } } package […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API17 May 2006

How do I create an empty collection object?

Sometimes you need to return an empty collection from your Java methods. The java.util.Collections utility class have three different static constants for creating empty List, Set and Map. Collections.EMPTY_LIST Collections.EMPTY_SET Collections.EMPTY_MAP There are also methods when you want to create type-safe empty collections. Collections.emptyList() Collections.emptySet() Collections.emptyMap() Bellow it the code example. package org.kodejava.util; import java.util.*; […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons13 May 2006

How do I write string data to file?

The following code snippet shows you how to write strings of data into a file using the Apache Commons IO library. We can use the FileUtils.writeStringToFile() method to do it. This method accepts the file object where the data will be stored, the data itself, and the encoding. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons12 May 2006

How do I calculate directory size?

In this example, we are going to use the Apache Commons IO library to get or calculate the total size of a directory. The FileUtils class provided by the Commons IO can help us to achieve this goal. The first method that we can use is the FileUtils.sizeOfDirectory(), it calculates the size of a directory […]

Wayan · 2 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.