|
Apple Java Extensions | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.apple.eio.FileManager
public class FileManager
Provides functionality to query and modify Mac-specific file attributes. The methods in this class are based on Finder attributes. These attributes in turn are dependent on HFS and HFS+ file systems. As such, it is important to recognize their limitation when writing code that must function well across multiple platforms.
In addition to file name suffixes, Mac OS X can use Finder attributes like file type
and creator
codes to
identify and handle files. These codes are unique 4-byte identifiers. The file type
is a string that describes the
contents of a file. For example, the file type APPL
identifies the file as an application and therefore
executable. A file type of TEXT
means that the file contains raw text. Any application that can read raw
text can open a file of type TEXT
. Applications that use proprietary file types might assign their files a proprietary
file type
code.
To identify the application that can handle a document, the Finder can look at the creator
. For example, if a user
double-clicks on a document with the ttxt
creator
, it opens up in Text Edit, the application registered
with the ttxt
creator
code. Note that the creator
code should possibly assigned not to match
not the application that created a document but the application that should ultimately handle the document. For example, if you
use an editor to create an HTML document, you might want to assign a browser's creator
code for the file rather than
the HTML editor's creator
code. Double-clicking on the document then opens the appropriate browser rather than the
HTML editor.
If you plan to publicly distribute your application, you must register its creator and any proprietary file types with the Apple Developer Connection to avoid collisions with codes used by other developers. You can register a codes online at the Creator Code Registration site.
Field Summary | |
---|---|
static short |
kLocalDomain
All users of a single machine have access to these resources. |
static short |
kNetworkDomain
All users configured to use a common network server has access to these resources. |
static short |
kOnAppropriateDisk
The default |
static short |
kSystemDomain
Read-only system hierarchy. |
static short |
kUserDomain
Read/write. |
Constructor Summary | |
---|---|
FileManager()
|
Method Summary | |
---|---|
static java.lang.String |
findFolder(int folderType)
Locates a folder of a particular type. |
static java.lang.String |
findFolder(short domain,
int folderType)
Locates a folder of a particular type, within a given domain. |
static java.lang.String |
findFolder(short domain,
int folderType,
boolean createIfNeeded)
Locates a folder of a particular type within a given domain and optionally creating the folder if it does not exist. |
static int |
getFileCreator(java.lang.String filename)
Obtains the file creator code for a file or folder. |
static int |
getFileType(java.lang.String filename)
Obtains the file type code for a file or folder. |
static java.lang.String |
getResource(java.lang.String resourceName)
Documentation Forthcoming |
static java.lang.String |
getResource(java.lang.String resourceName,
java.lang.String subDirName)
Documentation Forthcoming |
static void |
openURL(java.lang.String url)
Opens the path specified by a URL in the appropriate application for that URL. |
static int |
OSTypeToInt(java.lang.String type)
Converts an OSType (e.g. |
static void |
setFileCreator(java.lang.String filename,
int creator)
Sets the file creator code for a file or folder. |
static void |
setFileType(java.lang.String filename,
int type)
Sets the file type code for a file or folder. |
static void |
setFileTypeAndCreator(java.lang.String filename,
int type,
int creator)
Sets the file type and creator codes for a file or folder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short kOnAppropriateDisk
public static final short kSystemDomain
public static final short kLocalDomain
public static final short kNetworkDomain
public static final short kUserDomain
Constructor Detail |
---|
public FileManager()
Method Detail |
---|
public static int OSTypeToInt(java.lang.String type)
type
- the 4 character type to convert.
public static void setFileTypeAndCreator(java.lang.String filename, int type, int creator) throws java.io.IOException
type
and creator
codes for a file or folder.
java.io.IOException
public static void setFileType(java.lang.String filename, int type) throws java.io.IOException
type
code for a file or folder.
java.io.IOException
public static void setFileCreator(java.lang.String filename, int creator) throws java.io.IOException
creator
code for a file or folder.
java.io.IOException
public static int getFileType(java.lang.String filename) throws java.io.IOException
type
code for a file or folder.
java.io.IOException
public static int getFileCreator(java.lang.String filename) throws java.io.IOException
creator
code for a file or folder.
java.io.IOException
public static java.lang.String findFolder(int folderType) throws java.io.FileNotFoundException
root
folder, there
are multiple pref
folders. If this method is called to find the pref
folder, it will
return the first one it finds, the user's preferences folder in ~/Library/Preferences
. To explicitly
locate a folder in a certain domain use findFolder(short domain, int folderType)
or
findFolder(short domain, int folderType, boolean createIfNeeded)
.
java.io.FileNotFoundException
public static java.lang.String findFolder(short domain, int folderType) throws java.io.FileNotFoundException
findFolder(int folderType)
except that the domain to look in can be specified. Valid values for domain
include:
java.io.FileNotFoundException
public static java.lang.String findFolder(short domain, int folderType, boolean createIfNeeded) throws java.io.FileNotFoundException
findFolder(int folderType)
and findFolder(short domain, int folderType)
except that it can create the folder if it does not already exist.
createIfNeeded
- set to true
, by setting to false
the behavior will be the same as
findFolder(short domain, int folderType, boolean createIfNeeded)
java.io.FileNotFoundException
public static void openURL(java.lang.String url) throws java.io.IOException
http://
) open in the
default browser as set in the Internet pane of System Preferences. File (file://
) and FTP URL's (ftp://
)
open in the Finder. Note that opening an FTP URL will prompt the user for where they want to save the downloaded file(s).
url
- the URL for the file you want to open, it can either be an HTTP, FTP, or file url
java.io.IOException
public static java.lang.String getResource(java.lang.String resourceName) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public static java.lang.String getResource(java.lang.String resourceName, java.lang.String subDirName) throws java.io.FileNotFoundException
java.io.FileNotFoundException
|
Apple Java Extensions | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |