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 Commons01 Sep 2008

How do I decode a Base64 encoded binary?

package org.kodejava.commons.codec; import org.apache.commons.codec.binary.Base64; import java.util.Arrays; public class Base64Decode { public static void main(String[] args) { String hello = "SGVsbG8gV29ybGQ="; // Decode a previously encoded string using decodeBase64 method and // passing the byte[] of the encoded string. byte[] decoded = Base64.decodeBase64(hello.getBytes()); // Print the decoded array System.out.println(Arrays.toString(decoded)); // Convert the decoded byt...

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

How do I encode binary data as Base64 string?

package org.kodejava.commons.codec; import org.apache.commons.codec.binary.Base64; import java.util.Arrays; public class Base64Encode { public static void main(String[] args) { String hello = "Hello World"; // The encodeBase64 method take a byte[] as the parameter. The byte[] // can be from a simple string like in this example, or it can be from // an image file data. byte[] […]

Wayan · 1 min read
APACHE COMMONS / NOTES</>↗
Apache Commons16 Aug 2008

How do I sort files based on their last modified date?

This example demonstrates how to use Apache Commons IO LastModifiedFileComparator class to sort files based on their last modified date in ascending and descending order. There are two comparators defined in this class, the LASTMODIFIED_COMPARATOR and the LASTMODIFIED_REVERSE. package org.kodejava.commons.io; import static org.apache.commons.io.comparator.LastModifiedFileComparator.*; import java.io.File; import java.util.Arrays; public class FileSortLastModified { public sta...

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

How do I search for files recursively using Apache Commons IO?

This example demonstrates how we can use the FileUtils class listFiles() method to search for a file specified by their extensions. We can also define to find the file recursively deep down into the subdirectories. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.util.Collection; public class SearchFileRecursive { public static void main(String[] args) { File root […]

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

How do I delete file from FTP server?

This example demonstrates how to delete file from FTP server. package org.kodejava.commons.net; import org.apache.commons.net.ftp.FTPClient; import java.io.IOException; public class FTPDeleteDemo { public static void main(String[] args) { FTPClient client = new FTPClient(); try { client.connect("ftp.example.com"); client.login("demo", "password"); // Delete file on the FTP server. When the FTP delete // process completes, it returns true. String filename […]

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

How do I get a list of files from FTP server?

This example demonstrates how to retrieve a list of files from FTP server. First we create an instance of org.apache.commons.net.ftp.FTPClient. Connect to the FTP server and login with your username and password. The listFiles() method of the FTPClient return the list of filenames contained in the current working directory. null if the list could not […]

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.