In this article, I show you, using an example, how the Java ByteBuffer works, and what precisely the Methoden flip() and compact() do. The article answers the following questions: What is a ByteBuffer, and what do you need it for? How do you create a ByteBuffer? What do the values position, limit, and capacity mean?
The previous five parts of this article series covered reading and writing files, directory and file path construction, directory and file operations, and writing and reading structured data. In today’s part, I explain the NIO classes FileChannel and ByteBuffer introduced in Java 1.4 with JSR 51 (“New I/O APIs for the JavaTM Platform”). Moreover, I
In the first four parts of this article series, we covered reading and writing files, directory and file path construction, and directory and file operations. Up to now, we have only read and written byte arrays and Strings. In this fifth part, you will learn how to write and read structured data with DataOutputStream, DataInputStream,
Previous articles in this series have covered reading files with Java, writing files, and constructing directory and file paths with the File and Path classes. This fourth part describes the most important directory and file operations. It answers the following questions: How to list all files in a directory? How to search for files matching
After covering file reading and writing operations in Java, this third part of the series of articles deals with how to use the classes File, Path, and Paths to construct file and directory paths – regardless of the operating system. If you have already dealt with file operations in Java, you have probably used these
After the first part of the series was about reading files in Java, this second part introduces the corresponding methods for writing small and large files. The article addresses the following questions in detail: What is the easiest way to write a string or a list of strings to a text file? How to write