Links in NIO.2

One of the most important features in the NIO.2 library is the introduction of mechanism to work with links directly from your Java code (this was not possible to do without the use of native code in previous IO libraries). Most of the advanced users are already familiar with concept of hard links and symbolic links. Before we start to talk about links lets review some basic characteristics of both types:

  • Hard link or simply link is a directory entry that links file with name in given file system. Single file can be linked using multiple hard links. Hard link must always have an existing  target and this target can only be a file. User does not lose access to a target file by removing a hard link. Hard link provides linked file even after the target file was removed. Hard links are always bound to a single file system.
  • Symbolic link or soft link is a specific file containing relative or absolute path to a target file. Single file can be linked using multiple symbolic links. Symbolic links do not require an existing target and their target might be file or directory. User does not lose access to a target file by removing a symbolic link. Symbolic link is not influenced by removing of the target file, since its target is not required to exist. These kind of links are called dead links or broken links. Symbolic links are not bound to a single file system.

Continue reading “Links in NIO.2”