What is a FileSystem?

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

If you use a Unix-based operating system, this concept will be familiar; if not, it may require some explanation.

NetBeans uses virtual files to refer to the users files on disk, and to refer to its own configuration files. If you used the NetBeans IDE 3.6 or earlier, you may remember that the way you constructed your classpath used to be by "mounting" filesystems - folders on your disk.

Filesystems are gone from the UI, but are alive and well under the hood in NetBeans.

A FileSystem is a hierarchical tree of folders and files. A filesystem has a "root folder", which may contain files and other folders. "Files" (FileObjects ) in a Filesystem may be actual files on disk, or entries in JAR file, or entries in an XML file, or anything else that walks and talks like a file that someone has implemented the Filesystem interface for.

In the NetBeans Platform there are implementations of FileSystem for

  • plain disk files and folders

  • ZIP/JAR files

  • XML files in a predefined format ("layers")

  • a block of memory with no backing store

  • proxies for merging other filesystems with optional behavior overrides

Filesystems are used both to represent user files on disk, and also to represent configuration data internal to NetBeans - the System Filesystem . This is one of the reason that it takes only minimal code to create a GUI view of the system filesystem - the same file recognition code that recognizes user files, gives them actions, icons and display names is what recognizes internal configuration data.

Especially in the case of the System Filesystem, it can be useful to think of a Filesystem as a "namespace" in which objects (which may contain data or represent Java objects) live - for the System Filesystem, the fact that the entries in it are referred to as files is incidental.

As of NetBeans 4.0 you will rarely work directly with the FileSystem class. FileUtil.toFileObject is the normal way of getting a file object from a disk file. FileUtil.getArchiveRoot is the normal way of getting file objects from a JAR or ZIP file. In NetBeans 4.x FileSystem implementations are also used for version control integration but the 5.0 CVS support no longer uses this system.