Ruang penulis
SEBUAH JURNAL TENTANG TEKNOLOGI

Belajar hal baru.
Tulis. Bagikan.

Ruang untuk merangkai pengetahuan, satu baris kode setiap hari.
Temukan tutorial, ide, dan catatan dari perjalanan belajar.

1914 catatan & terus bertumbuh
UNTUK RASA INGIN TAHUMU

Catatan terbaru.

APACHE COMMONS / CATATAN</>
Apache Commons28 Mar 2010

How do I copy a URL into a file?

The code snippet below shows you how to use the FileUtils.copyURLToFile(URL, File) method of the Apache Commons IO library to help you to copy the contents of a URL directly into a file. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URL; public class URLToFile { public static void main(String[] args) { […]

Wayan · 1 menit baca
APACHE COMMONS / CATATAN</>
Apache Commons26 Mar 2010

How do I get free space of a drive or volume?

The getFreeSpaceKb(String path) method in the FileSystemUtils class can help you to calculate the free space of a drive or volume in kilobytes. Beside using commons-io solution, you can use the File.getFreeSpace() method call provided in the Java 1.6 API. You can find an example of it in the following link: How do I get […]

Wayan · 2 menit baca
APACHE COMMONS / CATATAN</>
Apache Commons22 Des 2009

How do I generate a random alphanumeric string?

The code below show you how to use the Apache Commons-Lang RandomStringUtils class to generate some random string data. package org.kodejava.commons.lang; import org.apache.commons.lang3.RandomStringUtils; public class RandomStringUtilsDemo { public static void main(String[] args) { // Creates a 64-chars length random string of number. String result = RandomStringUtils.random(64, false, true); System.out.println("random = " + result); // Creates […]

Wayan · 2 menit baca
APACHE COMMONS / CATATAN</>
Apache Commons11 Des 2009

How do I read a file into byte array using Apache Commons IO?

The following example shows you how to read file contents into byte array. We use the IOUtils class of the Apache Commons IO library. package org.kodejava.commons.io; import org.apache.commons.io.IOUtils; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class FileToByteArray { public static void main(String[] args) { File file = new File("README.md"); try { InputStream is […]

Wayan · 1 menit baca
APACHE COMMONS / CATATAN</>
Apache Commons07 Sep 2009

How do I get the content of an InputStream as a String?

We can use the code below to convert the content of an InputStream into a String. At first, we use FileInputStream create to a stream to a file that going to be read. IOUtils.toString(InputStream input, String encoding) method gets the content of the InputStream and returns a string representation of it. package org.kodejava.commons.io; import org.apache.commons.io.IOUtils; […]

Wayan · 1 menit baca
APACHE COMMONS / CATATAN</>
Apache Commons03 Sep 2009

How do I create a web based file upload?

This example using the Apache Commons FileUpload library to create a simple application for uploading files. The program is divided into two parts, a form using JSP and a servlet for handling the upload process. To run the sample you need to download the Commons FileUpload and Commons IO get the latest stable version. The […]

Wayan · 4 menit baca

Pengetahuan tumbuh ketika dibagikan.

Simpan rasa ingin tahu. Selalu ada hal baru untuk dipelajari.

Jelajahi catatan ↗
Putu Adi Guna Permana
TENTANG PENULIS

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

Penulis dan pendiri Diary Coding — berbagi catatan, tutorial, dan pengalaman seputar pemrograman untuk siapa pun yang ingin terus belajar.