BitSets in Scala are much more fun than in Java

Recently I played with BitSets in Java because I needed an efficient way to store huge amounts of long values. For Java there is the java.util.BitSet class. It is a very efficient implementation when you only need to store bit values. Here is a trivial example on how to use it:

It is very […]

Using DirectoryStreams in Java 7

Java 7 comes with lot’s of new stuff for IO. The new interfaces and classes added to the java.nio package contain lot’s of useful functionality for working with files and other things like asynchronous IO. Here I want to show you a little bit about the interface DirectoryStream which is very useful when you want […]

How to make Java classes immutable

Immutable classes have been a hot topic lately. The rise of functional languages who operate mostly on immutable data and the advantage of immutable data when using multiple threads (correct immutable classes are thread safe) have also created a new interest in immutable data in Java. While some languages like Scala encourage (but do not […]

File system events with Java 7

In the last post, I showed how to listen to Linux file system events using C, Ruby and Python. In this post, we look at Java 7. Java 7 has several new classes in the java.nio.file package that let you listen to file system events. The number of events available is not as extensive as […]