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 Commons14 Jul 2008

How do I upload file to FTP server?

This example demonstrates how to upload file to FTP server. package org.kodejava.commons.net; import org.apache.commons.net.ftp.FTPClient; import java.io.IOException; import java.io.InputStream; public class FTPUploadDemo { public static void main(String[] args) { FTPClient client = new FTPClient(); String filename = "data.txt"; // Read the file from the resources folder. ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try (InputStream is = classLoad...

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons11 Jul 2008

How do I download file from FTP server?

This example demonstrates how to download a file from FTP server. To download a file, we first connect to the FTP server and then login by supplying the username and password. To download the file we call retrieveFile() method of the FTPClient object. This method takes two parameters, the remote filename and an OutputStream of […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons10 Jul 2008

How do I connect to FTP server?

The File Transfer Protocol (FTP) is a standard network protocol used to transfer computer files between a client and server on a computer network. The example below shows you how to connect to an FTP server. In this example we are using the FTPClient class of the Apache Commons Net library. To connect to the […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons10 Jul 2008

How do I touch a file using Apache Commons IO?

This example demonstrates a touch command just like Unix touch command. If the file to be touched doesn’t exist, a new empty file will be created. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; public class TouchFileExample { public static void main(String[] args) { try { File file = new File("Touch.dat"); // Touch the file. […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons09 Jul 2008

How do I delete directory recursively?

Using the FileUtils.deleteDirectory() from the Apache Commons IO library, we can simplify the process of deleting directory and everything below it recursively. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; public class DeleteDirectory { public static void main(String[] args) { try { File directory = new File("F:/Temp"); // Deletes a directory recursively. When a deletion […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons05 Jul 2008

How do I create a human-readable file size?

This example demonstrates how to create a human-readable file size using the FileUtils class of the Apache Commons IO library. The byteCountToDisplaySize() method take the file size in bytes and return a human-readable display of the file size in bytes, kilobytes, megabytes, gigabytes, etc. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; public class ReadableFileSize { public […]

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.