I am looking for a way to tell if a file represented by a file path can be successfully created. The scenario I am testing is a file path that is too long -- 300 characters, on Windows 7. What I have tried:
Files.get(filePath)
This does not throw.
file.getCanonicalFile()
This also does not throw.
!Files.exists(filePath) && !Files.notExists(filePath)
exists returns false and notExists returns true.
!file.canWrite()
canWrite returns true.
file.createNewFile()
This does not throw. "ls" indicates the file exists, however navigating to the containing directory in Windows Explorer shows the entire folder as empty. I had to use the command line to delete the bad file to get the folder contents to be displayed. This scenario is exactly the reason I want to validate the file path in the first place.
Any suggestions?