public abstract class FileSystemView extends Object
Java Licensees may want to provide a different implementation of FileSystemView to better handle a given operating system.
Constructor | Description |
---|---|
FileSystemView() |
Constructs a FileSystemView. |
Modifier and Type | Method | Description |
---|---|---|
File |
createFileObject |
Returns a File object constructed in dir from the given filename. |
File |
createFileObject |
Returns a File object constructed from the given path string. |
protected File |
createFileSystemRoot |
Creates a new File object for f with correct behavior for a file system root directory. |
abstract File |
createNewFolder |
Creates a new folder with a default folder name. |
File |
getChild |
Returns a File object which is normally constructed with new
File(parent, fileName) except when the parent and child are both special folders, in which case the File is a wrapper containing a ShellFolder object. |
File[] |
getChooserComboBoxFiles() |
Returns an array of files representing the values which will be shown in the file chooser selector. |
final File[] |
getChooserShortcutPanelFiles() |
Returns an array of files representing the values to show by default in the file chooser shortcuts panel. |
File |
getDefaultDirectory() |
Return the user's default starting directory for the file chooser. |
File[] |
getFiles |
Gets the list of shown (i.e. not hidden) files. |
static FileSystemView |
getFileSystemView() |
Returns the file system view. |
File |
getHomeDirectory() |
Returns the home directory. |
File |
getLinkLocation |
Returns the regular file referenced by the specified link file if the specified file is a shell interpreted link. |
File |
getParentDirectory |
Returns the parent directory of dir . |
File[] |
getRoots() |
Returns all root partitions on this system. |
String |
getSystemDisplayName |
Name of a file, directory, or folder as it would be displayed in a system file browser. |
Icon |
getSystemIcon |
Icon for a file, directory, or folder as it would be displayed in a system file browser. |
Icon |
getSystemIcon |
Returns an icon for a file, directory, or folder as it would be displayed in a system file browser for the requested size. |
String |
getSystemTypeDescription |
Type description for a file, directory, or folder as it would be displayed in a system file browser. |
boolean |
isComputerNode |
Used by UI classes to decide whether to display a special icon for a computer node, e.g. |
boolean |
isDrive |
Used by UI classes to decide whether to display a special icon for drives or partitions, e.g. a "hard disk" icon. |
boolean |
isFileSystem |
Checks if f represents a real directory or file as opposed to a special folder such as "Desktop" . |
boolean |
isFileSystemRoot |
Is dir the root of a tree in the file system, such as a drive or partition. |
boolean |
isFloppyDrive |
Used by UI classes to decide whether to display a special icon for a floppy disk. |
boolean |
isHiddenFile |
Returns whether a file is hidden or not. |
boolean |
isLink |
Returns whether the specified file denotes a shell interpreted link which can be obtained by the getLinkLocation(File) . |
boolean |
isParent |
On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem. |
boolean |
isRoot |
Determines if the given file is a root in the navigable tree(s). |
Boolean |
isTraversable |
Returns true if the file (directory) can be visited. |
public FileSystemView()
public static FileSystemView getFileSystemView()
public boolean isRoot(File f)
C:\
, D:\
, etc. Unix has one root, the "/"
directory. The default implementation gets information from the ShellFolder
class.f
- a File
object representing a directorytrue
if f
is a root in the navigable tree.public Boolean isTraversable(File f)
f
- the File
true
if the file/directory can be traversed, otherwise false
public String getSystemDisplayName(File f)
f
- a File
objectpublic String getSystemTypeDescription(File f)
f
- a File
objectpublic Icon getSystemIcon(File f)
The default implementation gets information from the ShellFolder class.
f
- a File
objectpublic Icon getSystemIcon(File f, int width, int height)
Example:
FileSystemView fsv = FileSystemView.getFileSystemView(); Icon icon = fsv.getSystemIcon(new File("application.exe"), 64, 64); JLabel label = new JLabel(icon);
f
- a File
object for which the icon will be retrievedwidth
- width of the icon in user coordinate system.height
- height of the icon in user coordinate system.IllegalArgumentException
- if an invalid parameter such as a negative size or a null file reference is passed.public boolean isParent(File folder, File file)
folder
- a File
object representing a directory or special folderfile
- a File
objecttrue
if folder
is a directory or special folder and contains file
.public File getChild(File parent, String fileName)
File
object which is normally constructed with new
File(parent, fileName)
except when the parent and child are both special folders, in which case the File
is a wrapper containing a ShellFolder object.parent
- a File
object representing a directory or special folderfileName
- a name of a file or folder which exists in parent
public boolean isFileSystem(File f)
f
represents a real directory or file as opposed to a special folder such as "Desktop"
. Used by UI classes to decide if a folder is selectable when doing directory choosing.f
- a File
objecttrue
if f
is a real file or directory.public abstract File createNewFolder(File containingDir) throws IOException
containingDir
- a File
object denoting directory to contain the new folderFile
object denoting the newly created folderIOException
- if new folder could not be createdpublic boolean isHiddenFile(File f)
f
- a File
objectFile
denotes a hidden filepublic boolean isFileSystemRoot(File dir)
dir
- a File
object representing a directorytrue
if f
is a root of a filesystempublic boolean isDrive(File dir)
dir
- a directoryfalse
alwayspublic boolean isFloppyDrive(File dir)
dir
- a directoryfalse
alwayspublic boolean isComputerNode(File dir)
dir
- a directoryfalse
alwayspublic File[] getRoots()
File
objects representing all root partitions on this systempublic File getHomeDirectory()
public File getDefaultDirectory()
File
object representing the default starting folderpublic File createFileObject(File dir, String filename)
dir
- an abstract pathname denoting a directoryfilename
- a String
representation of a pathnameFile
object created from dir
and filename
public File createFileObject(String path)
path
- String
representation of pathFile
object created from the given path
public File[] getFiles(File dir, boolean useFileHiding)
dir
- the root directory of files to be returneduseFileHiding
- determine if hidden files are returnedFile
objects representing files and directories in the given dir
. It includes hidden files if useFileHiding
is false.public File getParentDirectory(File dir)
dir
.dir
- the File
being querieddir
, or null
if dir
is null
public File[] getChooserComboBoxFiles()
File
objects. The array returned may be possibly empty if there are no appropriate permissions.public final File[] getChooserShortcutPanelFiles()
File
objects. The array returned may be possibly empty if there are no appropriate permissions.public boolean isLink(File file)
getLinkLocation(File)
.file
- a fileNullPointerException
- if file
equals null
SecurityException
- if the caller does not have necessary permissionspublic File getLinkLocation(File file) throws FileNotFoundException
null
if the specified file is not a shell interpreted link.file
- a filenull
.FileNotFoundException
- if the linked file does not existNullPointerException
- if file
equals null
SecurityException
- if the caller does not have necessary permissionsprotected File createFileSystemRoot(File f)
File
object for f
with correct behavior for a file system root directory.f
- a File
object representing a file system root directory, for example "/" on Unix or "C:\" on Windows.File
object
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/filechooser/FileSystemView.html