• Home
  • Java – How-Tos and Tutorials

Java – How-Tos and Tutorials

Java - How to Hack Integer and String With Deep Reflection - feature image

Deep Reflection: How to Hack Integer and String

I am currently reading the book “The Pragmatic Programmer” by Andrew Hunt and David Thomas. In this book, the authors give the following task: Which of these “impossible” things can happen? […]3. In C++: a = 2; b = 3; if (a + b != 5) exit(1); […] One of the correct answers is 3.

Read More »
ByteBuffer How to use flip() and compact() - Feature image

Java ByteBuffer: How to use flip() and compact()

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?

Read More »
FileChannel, ByteBuffer, Memory-mapped I/O, Locks - Feature image

Java files, part 6: FileChannel, ByteBuffer, Memory-mapped I/O, Locks

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

Read More »
Java files - Basics: writing files - Feature image

Java files, part 2: How to write files quickly and easily

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

Read More »
Java files - Basics: reading files - Feature image

Java files, part 1: How to read files easily and fast

The packages java.io and java.nio.file contain numerous classes for reading and writing files in Java. Since the introduction of the Java NIO.2 (New I/O) File API, it is easy to get lost – not only as a beginner. Since then, you can perform many file operations in several ways. This article series starts by introducing

Read More »

Page [tcb_pagination_current_page] of [tcb_pagination_total_pages]