0

In the Java 7 source code the class, Paths has a method - get(URI).

Within get(URI) exists:

 return FileSystems.getDefault().provider().getPath(uri);

FileSystems.getDefault() returns a reference to the default filesystem. But then, according to the docs, .provider() closes the file system and then .getPath(uri) is called. Could someone explain to me what is going on? Why does the file system seem to be closed and then returned?

It would be great if someone could give me the blow-by-blow on what is occurring in that return statement.

madth3
  • 7,275
  • 12
  • 50
  • 74
user465001
  • 806
  • 13
  • 29

2 Answers2

3

i think this is the line you are referring to:

Once a file system created by this provider is closed

That does not mean the provider closes the system. It is talking about how the provider handles things when the system gets closed. Which would happen at some later time.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
BevynQ
  • 8,089
  • 4
  • 25
  • 37
0

From - FileSystem.provider().

provider
public abstract FileSystemProvider provider()
Returns the provider that created this file system.

I don't see anything that that says that close is called.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Karthik T
  • 31,456
  • 5
  • 68
  • 87