SupportWriter space ↗
A JOURNAL ABOUT TECHNOLOGY

Learn something new.
Write. Share.

A space to connect knowledge, one line of code a day.
Discover tutorials, ideas, and notes from a learning journey.

1967 notes & counting ↙
FOR YOUR CURIOSITY

Latest notes.

APACHE COMMONS / NOTES</>↗
Apache Commons09 Jan 2012

How do I create a java.io.File object from URL?

The code snippet below uses the FileUtils.toFile(URL) method that can be found in the Apache Commons IO library to convert a URL into a File. The url protocol should be file or else null will be returned. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.Objects; public class URLToFileObject { public static […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons10 Aug 2011

How do I create a database connection pool?

This example shows you how to create a connection pool implementation using the Apache Commons DBCP library. package org.kodejava.commons.dbcp; import org.apache.commons.dbcp2.*; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import javax.sql.DataSource; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; public class ConnectionPoolExample { private static final String...

Wayan · 3 min read
APACHE COMMONS / NOTES</>↗
Apache Commons10 Aug 2011

How do I create a BasicDataSource object?

This example demonstrates how to use the BasicDataSource class of Apache Commons DBCP to create a basic requirements for database connection. The configuration of the data source can be defined using some property method provided by this class. The basic properties are the driver classname, connection url, username and password. After the datasource ready we […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons01 Jun 2011

How do I capitalize each word in a string?

This example show you how to capitalize a string. We use methods from WordUtils class provided by the Apache commons-text;. We can use the WordUtils.capitalize(str) or WordUtils.capitalizeFully(str). Let’s see an example below: package org.kodejava.commons.text; import org.apache.commons.text.WordUtils; public class WordCapitalize { public static void main(String[] args) { // Capitalizes all the whitespace separated words in a […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons31 Mar 2010

How do I move directory to another directory with its entire contents?

Below is an example to move one directory with all its child directory and files to another directory. We can use the FileUtils.moveDirectory() method to simplify the process. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; public class DirectoryMove { public static void main(String[] args) { String source = "F:/Temp/source"; File srcDir = new File(source); […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons31 Mar 2010

How do I copy directory with all its contents to another directory?

To copy a directory with the entire child directories and files we can use a handy method provided by the Apache Commons IO FileUtils.copyDirectory(). This method accepts two parameters, the source directory and the destination directory. The source directory should be available while if the destination directory doesn’t exist, it will be created. package org.kodejava.commons.io; […]

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.