Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.5.0)

E13403-06


oracle.ide.net
Class URLFileSystem

java.lang.Object
  extended by oracle.ide.net.URLFileSystem


public final class URLFileSystem
extends java.lang.Object

The URLFileSystem class is responsible for encapsulating the notion of file system operations on content that is pointed to by an URL.

The behavior of URLFileSystem can be extended by subclasses of URLFileSystemHelper. An instance of URLFileSystemHelper is registered with URLFileSystem in association with a particular protocol. Protocol-specific behavior can thus be encapsulated by a specific implementation of URLFileSystemHelper.


Nested Class Summary
static class URLFileSystem.FileInfo
          The FileInfo class encapsulates the information describing files returned by the ls(URL) and ls(URL, URLFilter) methods.

 

Method Summary
static void addExistsTest(URLExistsTest existsTest)
          Add an implementation of the URLExistsTest interface.
static void addURLFileSystemListener(java.net.URL rootURL, URLFileSystemListener listener)
          Adds an URLFileSystemListener instance to track file changes in the given root URL directory.
static void addURLStreamHandlerFactory(java.net.URLStreamHandlerFactory factory)
          Use this method to register additional instances of URLStreamHandlerFactory that should be used by the IDE when dealing with URLs.
static boolean canCreate(java.net.URL url)
          Tests whether the application can create the resource at the specified URL.
static boolean canDelete(java.net.URL url)
          Tests whether the application can delete the resource at the specified URL.
static java.net.URL canonicalize(java.net.URL url)
          Returns a canonical form of the URL, if one is available.
static boolean canRead(java.net.URL url)
          Tests whether the application can read the resource at the specified URL.
static boolean canWrite(java.net.URL url)
          Tests whether the application can modify the resource at the specified URL.
static java.net.URL convertSuffix(java.net.URL url, java.lang.String oldSuffix, java.lang.String newSuffix)
          Takes the given URL and checks if its URL.toString() representation ends with the specified oldSuffix.
static void copy(java.io.InputStream in, java.net.URL dst)
          Copies the contents of in to dst.
static void copy(java.net.URL src, java.io.File dst)
          Copies the contents at src to dst.
static void copy(java.net.URL src, java.net.URL dst)
          Copies the contents at src to dst.
static java.io.Reader createReader(java.net.URL url, java.lang.String encoding)
           
static java.net.URL createTempFile(java.lang.String prefix, java.lang.String suffix, java.net.URL directory)
          Creates a new empty temporary file in the specified directory using the given prefix and suffix strings to generate its name.
static boolean delete(java.net.URL url)
          Deletes the content pointed to by the specified URL.
static void deleteEx(java.net.URL url)
          Deletes the content pointed to by the specified URL.
static java.net.URL ensureSuffix(java.net.URL url, java.lang.String suffix)
          This method ensures that the specified URL ends with the specified suffix.
static boolean equals(java.net.URL url1, java.net.URL url2)
          Returns true if both of the specified URL parameters point to the same URL object or if the both URL parameters have the same protocol and the protocol helper determines that the URL objects are equal.
static boolean exists(java.net.URL url)
          Tests whether a resource at the specified URL location currently exists.
static URLFileSystemHelper findHelper(java.lang.String protocol)
          Returns the URLFileSystemHelper class that is currently registered to handle operations related to the specified protocol.
static URLFileSystemHelper findHelper(java.net.URL url)
          Returns the URLFileSystemHelper class that is currently registered to handle operations related to the specified URL.
protected static void fireRenameURLFileSystemEvent(java.net.URL newURL, java.net.URL oldURL, int eventType)
          Utility routine which will take care of firing the URLFileSystemEvent as specified.
protected static void fireURLFileSystemEvent(java.net.URL changedURL, int eventType)
          Utility routine which will take care of firing the URLFileSystemEvent as specified.
static java.net.URL getBaseParent(java.net.URL url, java.lang.String relativeSpec)
           
static javax.swing.Icon getDefaultIcon(java.net.URL url)
          Returns a standard Icon that can be used to represent the resource designated by the specified URL.
static java.lang.String getFileName(java.net.URL url)
          Returns the name of the file contained by the URL, not including any protocol, hostname authentication, directory path, anchor, or query.
static long getLength(java.net.URL url)
          Returns the size in bytes of the content pointed to by the specified URL.
protected static java.util.Map<URLFileSystemListener,java.util.List<java.net.URL>> getListenersAndTrackedRootURLs(java.util.Collection<java.net.URL> rootURLs)
          Fetch all the URLFileSystemListeners which track any of the specify root URLs.
static java.lang.String getName(java.net.URL url)
          Returns the name of the file contained by the URL, not including any protocol, hostname authentication, directory path, anchor, or query.
protected static java.util.List<java.net.URL> getNonExistentParents(java.net.URL rootURL, java.net.URL url)
          Utility routine to get the intermediate parents of url, up to, and including the rootURL that might not currently exist.
static java.net.URL getParent(java.net.URL url)
          Returns the URL representing the parent directory of the specified URL.
static java.lang.String getPath(java.net.URL url)
          Returns the path part of the URL.
static java.lang.String getPathNoExt(java.net.URL url)
          Returns the path part of the URL without the last file extension.
static java.lang.String getPlatformPathName(java.net.URL url)
          Returns the platform-dependent String representation of the URL; the returned string should be considered acceptable for users to read.
static java.lang.String getSuffix(java.net.URL url)
          If a dot ('.') occurs in the file name of the path portion of the URL, then all of the text starting at the last dot is returned, including the dot.
static java.lang.String getSystemDisplayName(java.net.URL url)
          Returns the name of a resource as it would be displayed in a system file browser.
static javax.swing.Icon getSystemIcon(java.net.URL url)
          Returns the Icon used by the operating system to represent the resource designated by the specified URL; if an Icon cannot be obtained from the operating system, then returns a standard Icon representing a file or folder, as appropriate.
static java.io.File getTempDirectory(java.net.URL url)
          Returns a temporal directory suitable for URLs whose protocol matches the one found in the specified URL.
If not match is found then the default temporal directory as specified by System.getProperty("java.io.tmpdir") will be returned.
protected static java.net.URL getTrackedRootURL(java.net.URL url)
          Fetches the root URL that is being tracked (if any) that contains the specified url.
protected static java.util.List<java.net.URL> getTrackedRootURLs(java.net.URL url)
          Fetch all root URLs that match the given URL.
static java.util.Collection<java.net.URL> getURLsForListener(URLFileSystemListener listener)
          Fetch the root URLs that are being tracked by the given listener instance.
static int hashCode(java.net.URL url)
          Returns a hash code for the specified URL consistent with equals(java.net.URL, java.net.URL).
protected static boolean hasListener(java.net.URL url)
          Gets whether any listeners are registered for a URL.
static boolean hasSuffix(java.net.URL url, java.lang.String suffix)
          Returns true if the path part of the URL ends with the given suffix String.
static boolean hasSuffix(java.net.URL url, java.lang.String[] suffixes)
          Returns true if the path part of the URL ends with any of the given suffixs String.
static boolean isBaseURLFor(java.net.URL url1, java.net.URL url2)
          Returns true if url1 represents a a directory and url2 points to a location within url1's directory tree.
static boolean isBound(java.net.URL url)
          This method tests whether the specified URL is bound to an existing resource, which may reside in memory (i.e.
static boolean isDirectory(java.net.URL url)
          Tests whether the location indicated by the URL is a directory.
static boolean isDirectoryPath(java.net.URL url)
          Tests whether the location indicated by the URL represents a directory path.
static boolean isHidden(java.net.URL url)
          Tests whether the resource indiciated by the URL is a hidden file.
static boolean isLocal(java.net.URL url)
          Determines whether the URL points to a resource on the local machine, or whether it requires network access.
static boolean isLocalFileSystemCaseSensitive()
          Returns true if the local file system is case sensitive.
static boolean isReadOnly(java.net.URL url)
          Returns true if the resource pointed to by the specified URL is read-only; returns false otherwise.
static boolean isRegularFile(java.net.URL url)
          Tests whether the resource indiciated by the URL is a regular file.
static boolean isRoot(java.net.URL url)
          Returns true if the specified URL corresponds to a root file system; false otherwise.
static boolean isValid(java.net.URL url)
          Tests whether the specified URL is valid.
static long lastModified(java.net.URL url)
          Returns the last modified time of the resource pointed to by the URL.
static java.net.URL[] list(java.net.URL url)
          Returns an array of URLs naming files and directories in the directory indicated by the URL.
static java.net.URL[] list(java.net.URL url, URLFilenameFilter filter)
          Returns an aray of URLs naming files and directories in the directory indicated by the URL.
static java.net.URL[] list(java.net.URL url, URLFilter filter)
          Returns an array of URLs naming files and directories in the directory indicated by the URL; the specified URLFilter is applied to determine which URLs will be returned.
static java.net.URL[] listRoots()
          Returns an array of URLs that represent the root file systems that are currently available.
static URLFileSystem.FileInfo[] ls(java.net.URL url)
           
static URLFileSystem.FileInfo[] ls(java.net.URL url, URLFilter filter)
           
static URLFileSystem.FileInfo[] lsCached(java.net.URL url)
           
static URLFileSystem.FileInfo[] lsCached(java.net.URL url, URLFilter filter)
           
static boolean mkdir(java.net.URL url)
          Creates the directory indicated by the URL.
static boolean mkdirs(java.net.URL url)
          Creates the directory indicated by the specified URL including any necessary but nonexistent parent directories.
protected static void notifyExistentParents(java.net.URL rootURL, java.util.List<java.net.URL> nonexistentParents)
          Deprecated. 
protected static void notifyNonexistentParents(java.util.List<java.net.URL> nonexistentParents)
          Utility routine to check if the given list of directories exist or not, and to fire events for them to notify clients that they had gotten created.
static java.io.InputStream openInputStream(java.net.URL url)
          Opens an InputStream for the location indicated by the specified URL.
static java.io.OutputStream openOutputStream(java.net.URL url)
          Opens an OutputStream for the location indicated by the specified URL.
static void registerHelper(java.lang.String protocol, URLFileSystemHelper helper)
          Registers the specified URLFileSystemHelper as the object that can handle URLFileSystem operations for URLs of the specified protocol.
static void removeURLFileSystemListener(java.net.URL rootURL, URLFileSystemListener listener)
          Removes an URLFileSystemListener instance from the given tracked root URL.
static void renameEx(java.net.URL oldURL, java.net.URL newURL)
           
static boolean renameTo(java.net.URL oldURL, java.net.URL newURL)
          Renames the resource indicated by the first URL to the name indicated by the second URL.
static boolean setLastModified(java.net.URL url, long time)
          Sets the last-modified timestamp of the resource indicated by the URL to the time specified by time.
static boolean setReadOnly(java.net.URL url, boolean readOnly)
          Sets the read-only status of the resource indicated by the URL according to the specified readOnly flag.
static java.lang.String toDisplayString(java.net.URL url)
          Returns a user-displayable form of the specified URL.
static java.lang.String toEncodedString(java.net.URL url)
          Returns a String representing the URL-encoded form of the specified URL.
static java.lang.String toEncodedString(java.net.URL url, java.lang.String encoding)
           
static java.lang.String toRelativeSpec(java.net.URL url, java.net.URL base)
           
static java.lang.String toRelativeSpec(java.net.URL url, java.net.URL base, boolean mustConsumeBase)
           

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Method Detail

registerHelper

public static void registerHelper(java.lang.String protocol,
                                  URLFileSystemHelper helper)
Registers the specified URLFileSystemHelper as the object that can handle URLFileSystem operations for URLs of the specified protocol.

If the protocol is null or the empty string or if helper is null, this method does nothing.


findHelper

public static URLFileSystemHelper findHelper(java.lang.String protocol)
Returns the URLFileSystemHelper class that is currently registered to handle operations related to the specified protocol. If there is no registered helper, then a default helper is returned that can produce a default result.

findHelper

public static URLFileSystemHelper findHelper(java.net.URL url)
Returns the URLFileSystemHelper class that is currently registered to handle operations related to the specified URL. If there is no registered helper, then a default helper is returned that can produce a default result.

addExistsTest

public static void addExistsTest(URLExistsTest existsTest)
Add an implementation of the URLExistsTest interface. The existsTest object will be called by the isBound() method to determine if an URL is unique.

addURLStreamHandlerFactory

public static void addURLStreamHandlerFactory(java.net.URLStreamHandlerFactory factory)
Use this method to register additional instances of URLStreamHandlerFactory that should be used by the IDE when dealing with URLs. This allows multiple factories to be used instead of just a single factory as required by URL. The factories are chained together in the order in which they are registered, which means that earlier factories get the first crack at handling an URL.

canonicalize

public static java.net.URL canonicalize(java.net.URL url)
Returns a canonical form of the URL, if one is available.

canRead

public static boolean canRead(java.net.URL url)
Tests whether the application can read the resource at the specified URL.
Returns:
true if and only if the specified URL points to a resource that exists and can be read by the application; false otherwise.

canWrite

public static boolean canWrite(java.net.URL url)
Tests whether the application can modify the resource at the specified URL.
Returns:
true if and only if the specified URL points to a file that exists and the application is allowed to write to the file; false otherwise.

canCreate

public static boolean canCreate(java.net.URL url)
Tests whether the application can create the resource at the specified URL. This method tests that all components of the path can be created. If the resource pointed by the URL is read-only, this method returns false.
Returns:
true if the resource at the specified URL exists or can be created; false otherwise.

canDelete

public static boolean canDelete(java.net.URL url)
Tests whether the application can delete the resource at the specified URL. If source control integration is enabled, this method will return true if the specified URL is under source control. Otherwise, if there is no source control integration enabled or if the URL is not under source control, then this method will return true if the URL is not read-only or false if the URL is read-only. If the URL does not exist, this method returns false.
Parameters:
url - The URL being checked whether it can be deleted.
Returns:
true if the resource at the specified URL exists and is either not read-only or is under source control; false otherwise.

isValid

public static boolean isValid(java.net.URL url)
Tests whether the specified URL is valid. If the resource pointed by the URL exists the method returns true. If the resource does not exist, the method tests that all components of the path can be created.
Returns:
true if the URL is valid.

convertSuffix

public static java.net.URL convertSuffix(java.net.URL url,
                                         java.lang.String oldSuffix,
                                         java.lang.String newSuffix)
Takes the given URL and checks if its URL.toString() representation ends with the specified oldSuffix. If it does, the suffix is replaced with newSuffix. Both suffix parameters must include the leading dot ('.') if the dot is part of the suffix. If the specified URL does not end with the oldSuffix, then the newSuffix is simply appended to the end of the original URL.

copy

public static void copy(java.net.URL src,
                        java.net.URL dst)
                 throws java.io.IOException
Copies the contents at src to dst. If the destination directory does not exist, it will be created. IOException is throw if: - failed to read the source contents - failed to create destination directory - failed to write source contents to the destination file
Throws:
java.io.IOException

copy

public static void copy(java.io.InputStream in,
                        java.net.URL dst)
                 throws java.io.IOException
Copies the contents of in to dst.
Throws:
java.io.IOException

copy

public static void copy(java.net.URL src,
                        java.io.File dst)
                 throws java.io.IOException
Copies the contents at src to dst.
Throws:
java.io.IOException

delete

public static boolean delete(java.net.URL url)
Deletes the content pointed to by the specified URL. If the content is a file (or analogous to a file), then the file is removed from its directory (or container). If the content is a directory (or analogous to a directory), then the directory is removed only if it is empty (i.e. contains no other files or directories).

To receive an IOException on deletion failure instead, use the deleteEx(URL) method.

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

deleteEx

public static void deleteEx(java.net.URL url)
                     throws java.io.IOException
Deletes the content pointed to by the specified URL. If the content is a file (or analogous to a file), then the file is removed from its directory (or container). If the content is a directory (or analogous to a directory), then the directory is removed only if it is empty (i.e. contains no other files or directories).
Throws:
java.io.IOException - if an I/O exception occurred while trying to delete the URL. The exception message will contain details on why the deletion failed.

ensureSuffix

public static java.net.URL ensureSuffix(java.net.URL url,
                                        java.lang.String suffix)
This method ensures that the specified URL ends with the specified suffix. The suffix does not necessarily have to start with a ".", so if a leading "." is required, the specified suffix must contain it -- e.g. ".java", ".class".

If the URL already ends in the specified suffix, then the URL itself is returned. Otherwise, a new URL is created with the the specified suffix appended to the original URL's path part, and the new URL is returned.

Returns:
An URL, based on the specified URL, whose path part ends with the specified suffix.
Throws:
java.lang.NullPointerException - if either the specified URL or suffix is null. The caller is responsible for checking that they are not null.

equals

public static boolean equals(java.net.URL url1,
                             java.net.URL url2)
Returns true if both of the specified URL parameters point to the same URL object or if the both URL parameters have the same protocol and the protocol helper determines that the URL objects are equal.

hashCode

public static int hashCode(java.net.URL url)
Returns a hash code for the specified URL consistent with equals(java.net.URL, java.net.URL).

exists

public static boolean exists(java.net.URL url)
Tests whether a resource at the specified URL location currently exists. The test for existence only checks the actual location and does not check any in-memory caches. To employ additional existential tests that do check in-memory caches, see isBound(URL).
Returns:
true if and only if a resource already exists at the specified URL location; false otherwise.

getDefaultIcon

public static javax.swing.Icon getDefaultIcon(java.net.URL url)
Returns a standard Icon that can be used to represent the resource designated by the specified URL.
See Also:
getSystemIcon(URL)

getFileName

public static java.lang.String getFileName(java.net.URL url)
Returns the name of the file contained by the URL, not including any protocol, hostname authentication, directory path, anchor, or query. This simply returns the simple filename. For example, if you pass in an URL whose string representation is:
protocol://host:1010/dir1/dir2/file.ext#anchor?query
the returned value is "file.ext" (without the quotes).
Returns:
The simple filename of the specified URL. This value should only be used for display purposes and not for opening streams or otherwise trying to locate the document.

getLength

public static long getLength(java.net.URL url)
Returns the size in bytes of the content pointed to by the specified URL.
Returns:
the size in bytes of the document at the specified URL.

getName

public static java.lang.String getName(java.net.URL url)
Returns the name of the file contained by the URL, not including any protocol, hostname authentication, directory path, anchor, or query. This simply returns the simple filename. For example, if you pass in an URL whose string representation is:
protocol://host:1010/dir1/dir2/file.ext1.ext2#anchor?query
the returned value is "file.ext1" (without the quotes).

The returned file name should only be used for display purposes and not for opening streams or otherwise trying to locate the resource indicated by the URL.

The default implementation first calls getFileName(URL) to get the file name part. Then all characters starting with the last occurrence of '.' are removed. The remaining string is then returned.

Note: The implementation of this method changed in the 11.1.1 release of the platform to trim the filename on the last '.'. In previous releases of the platform, it would trim the filename on the first '.'.


getParent

public static java.net.URL getParent(java.net.URL url)
Returns the URL representing the parent directory of the specified URL. If there is no parent directory, then null is returned.

getPath

public static java.lang.String getPath(java.net.URL url)
Returns the path part of the URL. The returned string is acceptable to use in one of the URLFactory methods that takes a path.

The default implementation delegates to URL.getPath().


getPathNoExt

public static java.lang.String getPathNoExt(java.net.URL url)
Returns the path part of the URL without the last file extension. To clarify, the following examples demonstrate the different cases that come up:
Path part of input URL
Output String
/dir/file.ext /dir/file
/dir/file.ext1.ext2 /dir/file.ext1
/dir1.ext1/dir2.ext2/file.ext1.ext2 /dir1.ext1/dir2.ext2/file.ext1
/file.ext /file
/dir.ext/file /dir.ext/file
/dir/file /dir/file
/file /file
/.ext /

getPlatformPathName

public static java.lang.String getPlatformPathName(java.net.URL url)
Returns the platform-dependent String representation of the URL; the returned string should be considered acceptable for users to read. In general, the returned string should omit as many parts of the URL as possible. For the "file" protocol, therefore, the platform pathname should just be the pathname alone (no protocol) using the appropriate file separator character for the current platform. For other protocols, it may be necessary to reformat the URL string into a more human-readable form. That decision is left to each URLFileSystemHelper implementor.
Returns:
The path portion of the specified URL in platform-dependent notation. This value should only be used for display purposes and not for opening streams or otherwise trying to locate the document.

getSuffix

public static java.lang.String getSuffix(java.net.URL url)
If a dot ('.') occurs in the file name of the path portion of the URL, then all of the text starting at the last dot is returned, including the dot. If the last dot is also the last character in the path, then the dot by itself is returned. If there is no dot in the file name (even if a dot occurs elsewhere in the path), then the empty string is returned.

Examples:


getSystemDisplayName

public static java.lang.String getSystemDisplayName(java.net.URL url)
Returns the name of a resource as it would be displayed in a system file browser. For example, on Windows the "E:\" directory might be displayed as "CD Drive (E:)".
See Also:
getSystemIcon(URL)

getSystemIcon

public static javax.swing.Icon getSystemIcon(java.net.URL url)
Returns the Icon used by the operating system to represent the resource designated by the specified URL; if an Icon cannot be obtained from the operating system, then returns a standard Icon representing a file or folder, as appropriate.
See Also:
getDefaultIcon(URL), getSystemDisplayName(URL)

hasSuffix

public static boolean hasSuffix(java.net.URL url,
                                java.lang.String suffix)
Returns true if the path part of the URL ends with the given suffix String. The suffix can be any String and doesn't necessarily have to be one that begins with a dot ('.'). If you are trying to test whether the path part of the URL ends with a particular file extension, then the suffix parameter must begin with a '.' character to ensure that you get the right return value.

hasSuffix

public static boolean hasSuffix(java.net.URL url,
                                java.lang.String[] suffixes)
Returns true if the path part of the URL ends with any of the given suffixs String. The suffixs can be any String and doesn't necessarily have to be one that begins with a dot ('.'). If you are trying to test whether the path part of the URL ends with a particular file extension, then the suffixs parameter must begin with a '.' character to ensure that you get the right return value.

isBaseURLFor

public static boolean isBaseURLFor(java.net.URL url1,
                                   java.net.URL url2)
Returns true if url1 represents a a directory and url2 points to a location within url1's directory tree.

isBound

public static boolean isBound(java.net.URL url)
This method tests whether the specified URL is bound to an existing resource, which may reside in memory (i.e. not yet saved) or already exist at the URL location. This is similar to exists(URL) but differs in that additional tests are applied that check whether the URL is bound to an in-memory object before the actual URL location is checked.

More precisely, "bound" means either that an URL is being used in such a way that a registered URLExistsTest is able to detect the URL's usage or that a document already exists at the URL location as determined by exists(URL)).

Checking for uniqueness of a newly generated URL is the primary use for this method.


isLocal

public static boolean isLocal(java.net.URL url)
Determines whether the URL points to a resource on the local machine, or whether it requires network access.
Parameters:
url - the URL
Returns:
true if the URL is local, false if it requires network access

isLocalFileSystemCaseSensitive

public static boolean isLocalFileSystemCaseSensitive()
Returns true if the local file system is case sensitive. Returns false if the local file system is not case sensitive.

isDirectory

public static boolean isDirectory(java.net.URL url)
Tests whether the location indicated by the URL is a directory.
Returns:
true if and only if the location indicated by the URL exists and is a directory; false otherwise.

isDirectoryPath

public static boolean isDirectoryPath(java.net.URL url)
Tests whether the location indicated by the URL represents a directory path. The directory path specified by the URL need not exist.

This method is intended to be a higher performance version of the isDirectory(URL) method. Implementations of this method should attempt to ascertain whether the specified URL represents a directory path by simply examining the URL itself. Time consuming i/o operations should be avoided.

Returns:
true if the location indicated by the URL represents a directory path; the directory path need not exist.

isHidden

public static boolean isHidden(java.net.URL url)
Tests whether the resource indiciated by the URL is a hidden file. The exact definition of hidden is protocol-dependent and possibly system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.'). On Win32 systems, a file is considered to be hidden if it has been marked as such in the file system.

isReadOnly

public static boolean isReadOnly(java.net.URL url)
Returns true if the resource pointed to by the specified URL is read-only; returns false otherwise. If the read-only status cannot be determined for some reason, this method returns true.
Returns:
true if the document pointed to by the specified URL is read-only or if the read-only status cannot be determined; false otherwise.

isRegularFile

public static boolean isRegularFile(java.net.URL url)
Tests whether the resource indiciated by the URL is a regular file. A regular is a file that is not a directory and, in addition, satisfies other system-dependent criteria.
Returns:
true if and only if the resource indicated by the URL exists and is a normal file.

isRoot

public static boolean isRoot(java.net.URL url)
Returns true if the specified URL corresponds to a root file system; false otherwise.

listRoots

public static java.net.URL[] listRoots()
Returns an array of URLs that represent the root file systems that are currently available. The determination of the roots is delegated to each registered URLFileSystemHelper.

lastModified

public static long lastModified(java.net.URL url)
Returns the last modified time of the resource pointed to by the URL. The returned long is the number of milliseconds since the epoch (00:00:00 GMT Jan 1, 1970). If no timestamp is available or if the URL passed in is null, -1 is returned.
Returns:
The last modified time of the document pointed to by the specified URL.

list

public static java.net.URL[] list(java.net.URL url)
Returns an array of URLs naming files and directories in the directory indicated by the URL. If the specified URL does not represent a directory, then this method returns null. Otherwise, an array of URLs is returned, one for each file or directory in the directory. URLs representing the directory itself or its parent are not included in the result. There is no guarantee that the URLs will occur in any particular order.
Returns:
An array of URLs naming the files and directories in the directory indicated by the URL. The array will be empty if the directory is empty. Returns null if the URL does not represent a directory or if an I/O error occurs.

list

public static java.net.URL[] list(java.net.URL url,
                                  URLFilter filter)
Returns an array of URLs naming files and directories in the directory indicated by the URL; the specified URLFilter is applied to determine which URLs will be returned. If the specified URL does not represent a directory, then this method returns null. Otherwise, an array of URLs is returned, one for each file or directory in the directory that is accepted by the specified filter. URLs representing the directory itself or its parent are not included in the result. There is no guarantee that the URLs will occur in any particular order.

If the specified URLFilter is null then no filtering behavior is done.

Returns:
An array of URLs naming the files and directories in the directory indicated by the URL that are accepted by the specified URLFilter. The array will be empty if the directory is empty. Returns null if the URL does not represent a directory or if an I/O error occurs.

list

public static java.net.URL[] list(java.net.URL url,
                                  URLFilenameFilter filter)
Returns an aray of URLs naming files and directories in the directory indicated by the URL. The specified URLFilenameFilter is applied to determine which URLs will be returned.

This method has better performance characteristics for some protocols than list(URL,URLFilter) if you are able to filter out URLs based only on their name, because helpers may be able to avoid IO on children of the directory url.

Parameters:
url - a directory URL to list. Must be a directory URL, and must not be null.
filter - a filter implementation. May be null, in which case this method behaves exactly like list(URL).
Returns:
an array of URLs naming the files and directories in the directory indicated by the URL that are accepted by the specified URLFilenameFilter. The array will be empty if the directory is empty. Returns null if an IO error occurs.
Throws:
java.lang.NullPointerException - if the specified url is null.
Since:
11.0

ls

public static URLFileSystem.FileInfo[] ls(java.net.URL url)
See Also:
URLFileSystemHelper.ls(URL)

ls

public static URLFileSystem.FileInfo[] ls(java.net.URL url,
                                          URLFilter filter)
See Also:
URLFileSystemHelper.ls(URL, URLFilter)

lsCached

public static URLFileSystem.FileInfo[] lsCached(java.net.URL url)
See Also:
URLFileSystemHelper.ls(URL)

lsCached

public static URLFileSystem.FileInfo[] lsCached(java.net.URL url,
                                                URLFilter filter)
See Also:
URLFileSystemHelper.ls(URL, URLFilter)

mkdir

public static boolean mkdir(java.net.URL url)
Creates the directory indicated by the URL.
Returns:
true if and only if the directory was created; false otherwise.

mkdirs

public static boolean mkdirs(java.net.URL url)
Creates the directory indicated by the specified URL 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. This method returns true if the directory was created along with all necessary parent directories or if the directories already exist; it returns false otherwise.
Returns:
true if all directories were created successfully or exist; false if there was a failure somewhere. Note that even if false is returned, some directories may still have been created.

createTempFile

public static java.net.URL createTempFile(java.lang.String prefix,
                                          java.lang.String suffix,
                                          java.net.URL directory)
                                   throws java.io.IOException
Creates a new empty temporary file in the specified directory using the given prefix and suffix strings to generate its name.
Parameters:
prefix - The prefix string to be used in generating the file's name; must be at least three characters long
suffix - The directory in which the file is to be created, or null if the default temporary-file directory is to be used
directory - The directory in which the file is to be created, or null if the default temporary-file directory is to be used
Returns:
The URL to the temporary file.
Throws:
java.io.IOException

openInputStream

public static java.io.InputStream openInputStream(java.net.URL url)
                                           throws java.io.IOException
Opens an InputStream for the location indicated by the specified URL.
Parameters:
url - An InputStream is opened on the given URL. Depending on the protocol of the URL, this method may delegate to an URLFileSystemHelper or attempt to open the default InputStream through the URL's associated URLConnection.
Returns:
The InputStream associated with the URL.
Throws:
java.io.FileNotFoundException - if the resource at the specified URL does not exist.
java.io.IOException - if an I/O error occurs while creating the input stream.
java.net.UnknownServiceException - (a runtime exception) if the associated URLConnection.getInputStream() implementation does not support an InputStream.

openOutputStream

public static java.io.OutputStream openOutputStream(java.net.URL url)
                                             throws java.io.IOException
Opens an OutputStream for the location indicated by the specified URL.
Parameters:
url - An OutputStream is opened on the given URL. Depending on the protocol of the URL, this method may delegate to an URLFileSystemHelper or attempt to open the default OutputStream through the URL's associated URLConnection.
Returns:
The OutputStream associated with the URL.
Throws:
java.io.IOException - if an I/O error occurs while creating the output stream.
java.net.UnknownServiceException - (a runtime exception) if the associated URLConnection.getOutputStream() implementation does not support an OutputStream.

renameTo

public static boolean renameTo(java.net.URL oldURL,
                               java.net.URL newURL)
Renames the resource indicated by the first URL to the name indicated by the second URL.

If either URL parameter is null or if both of the specified URL parameters refer to the same resource, then the rename is not attempted and failure is returned.

If the specified URL parameters do not have the same protocol, then the URLFileSystem handles the rename by first copying the resource to the destination with copy(URL, URL) and then deleting the original resource with delete(URL); if either operation fails, then failure is returned.

Otherwise, the protocol helper is called to perform the actual rename operation. Protocol helper implementations may therefore assume that both URL parameters are not null, do not refer to the same resource, and have the same protocol.

If the original URL refers to a nonexistent resource, then the protocol helper implementations should return failure. It is left up to the protocol helper implementations to decide whether to overwrite the destination or return failure if the destination URL refers to an existing resource.

Parameters:
oldURL - the URL of the original resource
newURL - the desired URL for the renamed resource
Returns:
true if and only if the resource is successfully renamed; false otherwise.

renameEx

public static void renameEx(java.net.URL oldURL,
                            java.net.URL newURL)
                     throws java.io.IOException
Throws:
java.io.IOException

setLastModified

public static boolean setLastModified(java.net.URL url,
                                      long time)
Sets the last-modified timestamp of the resource indicated by the URL to the time specified by time. The time is specified in the number of milliseconds since the epoch (00:00:00 GMT Jan 1, 1970). The return value indicates whether or not the setting of the timestamp succeeded.

setReadOnly

public static boolean setReadOnly(java.net.URL url,
                                  boolean readOnly)
Sets the read-only status of the resource indicated by the URL according to the specified readOnly flag. The return value indicates whether or not the setting of the read-only flag succeeded.

toDisplayString

public static java.lang.String toDisplayString(java.net.URL url)
Returns a user-displayable form of the specified URL.

toEncodedString

public static java.lang.String toEncodedString(java.net.URL url)
Returns a String representing the URL-encoded form of the specified URL.

toEncodedString

public static java.lang.String toEncodedString(java.net.URL url,
                                               java.lang.String encoding)

toRelativeSpec

public static java.lang.String toRelativeSpec(java.net.URL url,
                                              java.net.URL base)
See Also:
URLFileSystemHelper.toRelativeSpec(URL, URL)

toRelativeSpec

public static java.lang.String toRelativeSpec(java.net.URL url,
                                              java.net.URL base,
                                              boolean mustConsumeBase)
See Also:
URLFileSystemHelper.toRelativeSpec(URL, URL, boolean)

getBaseParent

public static java.net.URL getBaseParent(java.net.URL url,
                                         java.lang.String relativeSpec)
See Also:
URLFileSystemHelper.getBaseParent(URL, String)

createReader

public static java.io.Reader createReader(java.net.URL url,
                                          java.lang.String encoding)
                                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
URLFileSystemHelper.createReader(URL, String)

fireURLFileSystemEvent

protected static void fireURLFileSystemEvent(java.net.URL changedURL,
                                             int eventType)
Utility routine which will take care of firing the URLFileSystemEvent as specified.
Parameters:
changedURL - the URL that was affected
eventType - the event that describing how the URL was affected

fireRenameURLFileSystemEvent

protected static void fireRenameURLFileSystemEvent(java.net.URL newURL,
                                                   java.net.URL oldURL,
                                                   int eventType)
Utility routine which will take care of firing the URLFileSystemEvent as specified. This is for a rename type event.
Parameters:
newURL - the new URL that was affected
oldURL - the old URL that was affected
eventType - the event that describing how the URL was affected

hasListener

protected static boolean hasListener(java.net.URL url)
Gets whether any listeners are registered for a URL.

getTrackedRootURL

protected static java.net.URL getTrackedRootURL(java.net.URL url)
Fetches the root URL that is being tracked (if any) that contains the specified url. This will return a root URL for which there is a registered URLFileSystemListener such that URLFileSystem.isBaseURLFor( rootURL, url ) returns true.
Parameters:
url - the URL for which we want to locate a tracked root URL
Returns:
the root URL (being tracked) which contains the given URL, or null if the URL is not contained in a tracked root URL

getListenersAndTrackedRootURLs

protected static java.util.Map<URLFileSystemListener,java.util.List<java.net.URL>> getListenersAndTrackedRootURLs(java.util.Collection<java.net.URL> rootURLs)
Fetch all the URLFileSystemListeners which track any of the specify root URLs. This reverses the map of root URLs to listeners, to a map of listeners to root URLs, filtered by the specified root URLs. Return the map of listeners to affected root URLs

getTrackedRootURLs

protected static java.util.List<java.net.URL> getTrackedRootURLs(java.net.URL url)
Fetch all root URLs that match the given URL. Return a list of all such root URLs, or null if the specified URL is null.

getNonExistentParents

protected static java.util.List<java.net.URL> getNonExistentParents(java.net.URL rootURL,
                                                                    java.net.URL url)
Utility routine to get the intermediate parents of url, up to, and including the rootURL that might not currently exist.

notifyNonexistentParents

protected static void notifyNonexistentParents(java.util.List<java.net.URL> nonexistentParents)
Utility routine to check if the given list of directories exist or not, and to fire events for them to notify clients that they had gotten created. This is a companion routine to getNonExistentParents( rootURL, url ).

notifyExistentParents

@Deprecated
protected static void notifyExistentParents(java.net.URL rootURL,
                                                       java.util.List<java.net.URL> nonexistentParents)
Deprecated. 

addURLFileSystemListener

public static void addURLFileSystemListener(java.net.URL rootURL,
                                            URLFileSystemListener listener)
Adds an URLFileSystemListener instance to track file changes in the given root URL directory. If the listener instance is already registered for the given root URL, then nothing happens.
Parameters:
rootURL - the root URL in which to track file changes such as file add, change, or remove events
listener - the listener instance to register

removeURLFileSystemListener

public static void removeURLFileSystemListener(java.net.URL rootURL,
                                               URLFileSystemListener listener)
Removes an URLFileSystemListener instance from the given tracked root URL. If the listener instance is not currently registered for the given root URL, then nothing happens.
Parameters:
rootURL - the root URL in which to no longer track file changes for the given listener
listener - the listener instance to de-register

getURLsForListener

public static java.util.Collection<java.net.URL> getURLsForListener(URLFileSystemListener listener)
Fetch the root URLs that are being tracked by the given listener instance. This is returned as a Collection.
Parameters:
listener - the listener for which we want to fetch the registered root URL instances
Returns:
a collection of registered root URLs

getTempDirectory

public static java.io.File getTempDirectory(java.net.URL url)
Returns a temporal directory suitable for URLs whose protocol matches the one found in the specified URL.
If not match is found then the default temporal directory as specified by System.getProperty("java.io.tmpdir") will be returned.
Returns:
A File, based on the specified URL, whose protocol matches the one found in the specified URL.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.5.0)

E13403-06


Copyright © 1997, 2011, Oracle. All rights reserved.