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 Commons05 May 2006

How do I read file contents to string using Commons IO?

In this example we use FileUtils class from Apache Commons IO to read the content of a file. FileUtils have two static methods called readFileToString(File) and readFileToString(File, String) that we can use. An example to read file contents and return the result as a string can be seen below. package org.kodejava.commons.io; import org.apache.commons.io.FileUtils; import java.io.File; […]

Wayan · 1 min read
ZIP AND GZIP / NOTES</>↗
Zip and GZIP05 May 2006

How do I read entries in a zip / compressed file?

package org.kodejava.util.zip; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class ZipFileExample { public static void main(String[] args) { try { // Create an instance of ZipFile to read a zip file // called sample.zip ZipFile zip = new ZipFile(new File("data.zip")); // Here we start to iterate each […]

Wayan · 2 min read
BASIC / NOTES</>↗
Basic04 May 2006

What is Autoboxing?

Autoboxing is a new feature offered in the Tiger (1.5) release of Java SDK. In short auto boxing is a capability to convert or cast between object wrappers (Integer, Long, etc) and their primitive types. Previously when placing primitive data into one of the Java Collection Framework object we have to wrap it to an […]

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

How do I use Java NIO to copy file?

The following code snippet show you how to copy a file using the NIO API. The NIO (New IO) API is in the java.nio.* package. It requires at least Java 1.4 because the API was first included in this version. The JAVA NIO is a block based IO processing, instead of a stream based IO […]

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

How do I split a string?

Prior to Java 1.4 we use java.util.StringTokenizer class to split a tokenized string, for example a comma separated string. Starting from Java 1.4 and later the java.lang.String class introduce a String.split(String regex) method that simplify this process. Below is a code snippet how to do it. package org.kodejava.lang; import java.util.Arrays; public class StringSplit { public […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API30 Apr 2006

How do I execute other applications from Java?

The following program allows you to run / execute other application from Java using the Runtime.exec() method. package org.kodejava.lang; import java.io.IOException; public class RuntimeExec { public static void main(String[] args) { //String command = "/Applications/Safari.app/Contents/MacOS/Safari"; String command = "explorer.exe"; try { Process process = Runtime.getRuntime().exec(new String[]{command}); } catch (IOException e) { e.printStackTrace(); } } }

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.