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.

IO / NOTES</>↗
IO02 Jan 2026

How do I zip and unzip files with Java I/O?

In Java, handling ZIP files is primarily done using the java.util.zip package. The key classes you’ll use are ZipOutputStream for creating (zipping) files and ZipInputStream (or ZipFile) for extracting (unzipping) them. Here is a breakdown of how to perform both operations. 1. Zipping Files To zip files, you wrap a FileOutputStream with a ZipOutputStream. For […]

Wayan · 3 min read
IO / NOTES</>↗
IO02 Jan 2026

How do I use Files.walk() to traverse directories?

To use Files.walk to traverse directories, you call the method with a starting Path. It returns a Stream<Path> that lazily populates as you traverse the file tree in a depth-first manner. The most important best practice when using Files.walk is to use it within a try-with-resources block. This ensures that the underlying resources (the directory […]

Wayan · 2 min read
IO / NOTES</>↗
IO01 Jan 2026

How do I create a temporary file with Files.createTempFile()?

To create a temporary file using java.nio.file.Files.createTempFile, you can use one of two main overloaded methods. This is part of the Java NIO.2 API and is generally preferred over the older File.createTempFile because it returns a Path object and allows for better error handling and file attributes. 1. In the Default Temporary Directory If you […]

Wayan · 2 min read
IO / NOTES</>↗
IO01 Jan 2026

How do I use Files.lines() to process a text file line by line?

To use Files.lines() to process a text file line by line in Java, you should follow the pattern of returning a Stream<String> within a try-with-resources block. This approach is memory-efficient because it reads the file lazily, meaning it doesn’t load the entire file into memory at once. Basic Implementation package org.kodejava.nio; import java.io.IOException; import java.nio.file.Files; […]

Wayan · 2 min read
IO / NOTES</>↗
IO31 Dec 2025

How do I use Files.newBufferedReader() with try-with-resources?

Using Files.newBufferedReader with a try-with-resources block is the best practice for reading files in Java. Since BufferedReader implements AutoCloseable, the try-with-resources statement ensures that the file handle is automatically closed when the block is finished, even if an exception occurs. Here is how you can implement it: Basic Usage This is the simplest way to […]

Wayan · 2 min read
IO / NOTES</>↗
IO31 Dec 2025

How do I read large files with streams?

Reading large files in Java efficiently is best achieved by using Stream-based APIs that process the file line-by-line or chunk-by-chunk. This prevents loading the entire file into memory (preventing OutOfMemoryError). Here are the most common and efficient ways to do this: 1. Using Files.lines() (Recommended) This is the most modern and idiomatic way in Java. […]

Wayan · 3 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.