Reputation: 1374
I'm trying to find something on the file system, so I'm digging all through the file system on my computer. However, I'm running into a lot of trouble. Java keeps finding these directories that are, for lack of a better term, super hidden. Meaning, they don't show up in Windows explorer even after setting hidden files to display. As soon as Java hits one of these hidden folders it gets confused and throws a null pointer exception.
Has anyone experienced this, know what these hidden folders are, or how to work around them?
To give an example, the folder that's currently breaking my script is
C:\Users\Public\Videos
And like I mentioned, this folder is invisible to Explorer. Java seems to not know how to handle it.
As an experiment, I created a File
from the path, and did a couple of exploratory commands.
File mysteryFile = new File("C:\\Users\\Public\\Videos")
System.out.println(mysteryFile.exists())
>>> true
System.out.println(mysteryFile.isHidden())
>>> false // so confusing!
Files.isReadable(Paths.get(mysteryFile.getAbsolutePath()))
>>> true
Anyone know what's going on here?
Upvotes: 0
Views: 243
Reputation: 20899
Windows is using "English folder names" under the hood. The Folder C:\Users\Public\Videos
will be renamed by windows explorer according to the language of the operating system.
On a german system for example it would be shown as C:\Benutzer\Öffentlich\Öffentliche Videos
Note, that there are A LOT of folders following this behaviour.
But no matter how it is shown in Windows Explorer - it's path is C:\Users\Public\Videos
.
If you hit WIN-KEY + R
and enter C:\Users\Public\Videos
- it will open the target directory in question.
Upvotes: 1