-1

The following code throws java.nio.file.FileSystemNotFoundException when run. What might be the reason?

Path p = Paths.get(new URI("file://e:/temp/records"));
Mishal
  • 33
  • 6
  • 1
    Does this answer your question? [java.nio.file.FileSystemNotFoundException when getting file from resources folder](https://stackoverflow.com/questions/29746667/java-nio-file-filesystemnotfoundexception-when-getting-file-from-resources-folde) – Oleksii Valuiskyi Jan 21 '21 at 08:24

1 Answers1

0

You have incorrectly specified the uri, it is missing a /. Try running these in JSHELL to see that the correct value is "file:///e:/temp/records":

Paths.get(new URI("file://e:/temp/records"))
==> \\e\temp\records      [ INCORRECT PATH]

Paths.get("e:\\temp\\records").toUri()
==> file:///e:/temp/records

Paths.get(new URI("file:///e:/temp/records"))
==> e:\temp\records     [ CORRECT PATH TO E: ]
DuncG
  • 12,137
  • 2
  • 21
  • 33