I was stuck for a few hours because in my conditional loop, the .isFile or .exists methods always returned false.. even when the file DID exist.
I wondered if it could be the string that I had passed to my file on initialization was being overwritten somehow.. but that wasn't the case, as I suspected.
It turned out that the directory or path the .isFile and .exists() methods look into are
C:\Users\MyComputerName\workspace\NameOfMyJavaProject\
directory.
This is the default where all of my stuff is stored. And so it all then clicked, it made sense why my boolean variable always returned false and allowed the creation of the same named file.. because it would look into the directory I posted above, NOT where I had the files being created.. Because I have the files created in my F:\
drive.
What could I do so that I could have the .isFile() and .exists() methods look into my F:\
drive?
Boolean exists = new File("F:\testFile.txt").exists();