Skip to content

Tag: nio

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? I think maybe there is another

How to get the inmediate child directory of a file path in Java?

I want to navigate the file system and get the path to the child of a directory (if exists) without the root. For example: Input: Users/Documents/SVG Output: Documents/SVG My solution so far is to hardcode a string manipulation of the path: Is there a more elegant way to do this? Answer Path.relativize() can help You can convert this Path back

When to use ** (double star) in glob syntax within JAVA

Directly from this Java Oracle tutorial: Two asterisks, **, works like * but crosses directory boundaries. This syntax is generally used for matching complete paths. Could anybody do a real example out of it? What do they mean with “crosses directory boundary”? Crossing the directory boundary, I imagine something like checking the file from root to getNameCount()-1. Again a real