Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phantom folders from Hell (old Vista install) causing Java String.equals() problems

I'm writing a program that searches directories of a computer. On my own computer I have a drive installed which previously booted Windows Vista.

(However, there are drives that do not appear even when "show hidden folders". I can see the folders running cmd, but that doesn't solve my problem.)

I don't care so much about the folders, but I do care about doing string comparisons with their names. However string.equals() and string.compareTo() does not work with these phantom folders when I get their name with File directory.getName().

I've printed out the names, checked for whitespace, used trim, etc. but a hidden folder named "Boot" will still not match with a string with same value.

TLDR: phantom directories return an unmatchable/comparable string with File directory.getName().

Besides solving the problem, I'm just curious to know what's going on.

like image 407
wnewport Avatar asked Feb 25 '26 04:02

wnewport


1 Answers

You may be getting hidden characters in the name. Check the string length of the Boot folder to see if it is four. Convert the String into an array of characters and examine each cell in a debugger.

like image 109
harschware Avatar answered Feb 26 '26 18:02

harschware