Skip to content

Tag: nio

Detect if 2 paths are hard-linked together

If I have 2 Paths for files, both share the same FileStore, how can I verify with Java 17 whether they are pointing to the same file on disk (are hard-linked)? For Unix-like systems there seems at least to be a way to verify whether a file has other hardlinks (get Hard Link Count in Java), but on Windows/NTFS…

Why Java Files.walkFileTree throw a NoSuchFileException?

I’m using Files.walkFileTree to delete a directory. When running this code in CentOS, I got an error in my server log. I searched some keywords on the internet and there is no answer yet, maybe something is wrong with my code. So I wonder is it because Files.walkFileTree is not thread safe or something?…

How to create a Path to a non existent file

How can I create a Path to a file which is guaranteed not to exist? I thought about using an “impossible” path name, such as: But somebody could create such a file, making my code fail. Update I have written a method which accepts a Path and then tries to read from the underlying file, and now I a…

How to send both commands and files using Netty

I don’t understand what I’m doing wrong. How to send both commands and files. Below are the server and client pipelines. client pipeline: server pipeline: The fact is that before I send the file, I send a command (FileInfo) that the file described in this FileInfo will be sent soon. Then the file …

Provider not found exception when creating a FileSystem for my zip?

I have created a Zip file on a JimFS FileSystem instance. I would now like to read the Zip using the Java FileSystem API. Here is how I create the FileSystem: However, this throws an error: java.nio.file.ProviderNotFoundException: Provider not found Interestingly, the code works with the default FileSystem. W…

Package org.jboss.netty.channel.socket.nio does not exist

Which JAR contains org.jboss.netty.channel.socket.nio? I’m not using Maven or Ivy, just Ant. Ant compile gives: In the classpath is: The library is netty-4.0.21.Final.tar.bz2, which was downloaded from the official Netty website. I added each JAR from that download to the project. Yes, I realize it&#821…