public abstract class

ShellFolder

extends File
java.lang.Object
   ↳ java.io.File
     ↳ sun.awt.shell.ShellFolder

Summary

Fields
protected ShellFolder parent
[Expand]
Inherited Fields
From class java.io.File
Public Methods
boolean canRead()
Tests whether the application can read the file denoted by this abstract pathname.
boolean canWrite()
Returns true if folder allows creation of children.
int compareTo(File file2)
Compares this ShellFolder with the specified ShellFolder for order.
boolean createNewFile()
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
boolean delete()
Deletes the file or directory denoted by this abstract pathname.
void deleteOnExit()
Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
boolean exists()
Tests whether the file or directory denoted by this abstract pathname exists.
static Object get(String key)
File getAbsoluteFile()
Returns the absolute form of this abstract pathname.
abstract String getDisplayName()
abstract String getExecutableType()
Object getFolderColumnValue(int column)
static Object getFolderColumnValue(File file, int column)
ShellFolderColumnInfo[] getFolderColumns()
static ShellFolderColumnInfo[] getFolderColumns(File dir)
abstract String getFolderType()
Image getIcon(boolean getLargeIcon)
abstract ShellFolder getLinkLocation()
static File getNormalizedFile(File f)
Canonicalizes files that don't have symbolic links in their path.
String getParent()
Returns the path for this object's parent, or null if this object does not name a parent folder.
File getParentFile()
Returns a File object representing this object's parent, or null if this object does not name a parent folder.
static ShellFolder getShellFolder(File file)
Return a shell folder from a file object
boolean isAbsolute()
Tests whether this abstract pathname is absolute.
static boolean isComputerNode(File dir)
Does dir represent a "computer" such as a node on the network, or "My Computer" on the desktop.
boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory.
boolean isFile()
Tests whether the file denoted by this abstract pathname is a normal file.
boolean isFileSystem()
static boolean isFileSystemRoot(File dir)
abstract boolean isLink()
long lastModified()
Returns the time that the file denoted by this abstract pathname was last modified.
long length()
Returns the length of the file denoted by this abstract pathname.
File[] listFiles(boolean includeHiddenFiles)
File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
boolean mkdir()
Creates the directory named by this abstract pathname.
boolean mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.
boolean renameTo(File dest)
Renames the file denoted by this abstract pathname.
boolean setLastModified(long time)
Sets the last-modified time of the file or directory named by this abstract pathname.
boolean setReadOnly()
Marks the file or directory named by this abstract pathname so that only read operations are allowed.
static void sortFiles(List files)
String toString()
Returns the pathname string of this abstract pathname.
Protected Methods
abstract Object writeReplace()
This method must be implemented to make sure that no instances of ShellFolder are ever serialized.
[Expand]
Inherited Methods
From class java.io.File
From class java.lang.Object
From interface java.lang.Comparable

Fields

protected ShellFolder parent

Public Methods

public boolean canRead ()

Tests whether the application can read the file denoted by this abstract pathname.

Returns
  • true if and only if the file specified by this abstract pathname exists and can be read by the application; false otherwise

public boolean canWrite ()

Returns true if folder allows creation of children. True for the "Desktop" folder, but false for the "My Computer" folder.

Returns
  • true if and only if the file system actually contains a file denoted by this abstract pathname and the application is allowed to write to the file; false otherwise.

public int compareTo (File file2)

Compares this ShellFolder with the specified ShellFolder for order.

Parameters
file2 The abstract pathname to be compared to this abstract pathname
Returns
  • Zero if the argument is equal to this abstract pathname, a value less than zero if this abstract pathname is lexicographically less than the argument, or a value greater than zero if this abstract pathname is lexicographically greater than the argument

public boolean createNewFile ()

Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.

Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

Returns
  • true if the named file does not exist and was successfully created; false if the named file already exists
Throws
IOException

public boolean delete ()

Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.

Returns
  • true if and only if the file or directory is successfully deleted; false otherwise

public void deleteOnExit ()

Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates. Files (or directories) are deleted in the reverse order that they are registered. Invoking this method to delete a file or directory that is already registered for deletion has no effect. Deletion will be attempted only for normal termination of the virtual machine, as defined by the Java Language Specification.

Once deletion has been requested, it is not possible to cancel the request. This method should therefore be used with care.

Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

public boolean exists ()

Tests whether the file or directory denoted by this abstract pathname exists.

Returns
  • true if and only if the file or directory denoted by this abstract pathname exists; false otherwise

public static Object get (String key)

Parameters
key a String
Returns
  • An Object matching the string key.
See Also
  • ShellFolderManager#get(String)

public File getAbsoluteFile ()

Returns the absolute form of this abstract pathname. Equivalent to new File(this.getAbsolutePath()).

Returns
  • The absolute abstract pathname denoting the same file or directory as this abstract pathname

public abstract String getDisplayName ()

Returns
  • The name used to display this shell folder

public abstract String getExecutableType ()

Returns
  • The executable type as a string

public Object getFolderColumnValue (int column)

public static Object getFolderColumnValue (File file, int column)

public ShellFolderColumnInfo[] getFolderColumns ()

public static ShellFolderColumnInfo[] getFolderColumns (File dir)

public abstract String getFolderType ()

Returns
  • The type of shell folder as a string

public Image getIcon (boolean getLargeIcon)

Parameters
getLargeIcon whether to return large icon (ignored in base implementation)
Returns
  • The icon used to display this shell folder

public abstract ShellFolder getLinkLocation ()

Returns
  • The shell folder linked to by this shell folder, or null if this shell folder is not a link

public static File getNormalizedFile (File f)

Canonicalizes files that don't have symbolic links in their path. Normalizes files that do, preserving symbolic links from being resolved.

Throws
IOException

public String getParent ()

Returns the path for this object's parent, or null if this object does not name a parent folder.

Returns
  • the path as a String for this object's parent, or null if this object does not name a parent folder
See Also

public File getParentFile ()

Returns a File object representing this object's parent, or null if this object does not name a parent folder.

Returns
  • a File object representing this object's parent, or null if this object does not name a parent folder
See Also

public static ShellFolder getShellFolder (File file)

Return a shell folder from a file object

Throws
FileNotFoundException if file does not exist

public boolean isAbsolute ()

Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\".

Returns
  • true if this abstract pathname is absolute, false otherwise

public static boolean isComputerNode (File dir)

Does dir represent a "computer" such as a node on the network, or "My Computer" on the desktop.

public boolean isDirectory ()

Tests whether the file denoted by this abstract pathname is a directory.

Returns
  • true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise

public boolean isFile ()

Tests whether the file denoted by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

Returns
  • true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise

public boolean isFileSystem ()

Returns
  • Whether this is a file system shell folder

public static boolean isFileSystemRoot (File dir)

Returns
  • Whether this is a file system root directory

public abstract boolean isLink ()

Returns
  • Whether this shell folder is a link

public long lastModified ()

Returns the time that the file denoted by this abstract pathname was last modified.

Returns
  • A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs

public long length ()

Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.

Returns
  • The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist. Some operating systems may return 0L for pathnames denoting system-dependent entities such as devices or pipes.

public File[] listFiles (boolean includeHiddenFiles)

public File[] listFiles ()

Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the File(File, String) constructor. Therefore if this pathname is absolute then each resulting pathname is absolute; if this pathname is relative then each resulting pathname will be relative to the same directory.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Returns
  • An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

public boolean mkdir ()

Creates the directory named by this abstract pathname.

Returns
  • true if and only if the directory was created; false otherwise

public boolean mkdirs ()

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

Returns
  • true if and only if the directory was created, along with all necessary parent directories; false otherwise

public boolean renameTo (File dest)

Renames the file denoted by this abstract pathname.

Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful.

Parameters
dest The new abstract pathname for the named file
Returns
  • true if and only if the renaming succeeded; false otherwise

public boolean setLastModified (long time)

Sets the last-modified time of the file or directory named by this abstract pathname.

All platforms support file-modification times to the nearest second, but some provide more precision. The argument will be truncated to fit the supported precision. If the operation succeeds and no intervening operations on the file take place, then the next invocation of the lastModified() method will return the (possibly truncated) time argument that was passed to this method.

Parameters
time The new last-modified time, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
Returns
  • true if and only if the operation succeeded; false otherwise

public boolean setReadOnly ()

Marks the file or directory named by this abstract pathname so that only read operations are allowed. After invoking this method the file or directory is guaranteed not to change until it is either deleted or marked to allow write access. Whether or not a read-only file or directory may be deleted depends upon the underlying system.

Returns
  • true if and only if the operation succeeded; false otherwise

public static void sortFiles (List files)

public String toString ()

Returns the pathname string of this abstract pathname. This is just the string returned by the getPath() method.

Returns
  • The string form of this abstract pathname

Protected Methods

protected abstract Object writeReplace ()

This method must be implemented to make sure that no instances of ShellFolder are ever serialized. If isFileSystem() returns true, then the object should be representable with an instance of java.io.File instead. If not, then the object is most likely depending on some internal (native) state and cannot be serialized.