Microedition io file fileconnection version
File and its related classes to support such access, but these APIs are too heavyweight to be useful on mobile devices. On devices that implement JSR 75, this package enables J2ME-based applications to create, read, and write files and directories located on mobile devices and external memory cards.
Because any device that meets the minimum requirements of CLDC 1. In general, neither end users nor application developers can download an optional package and install it in the device.
An application that relies on an optional package will run properly only if that package is already installed. FileConnection Interface for access to files or directories. FileSystemListener Listener interface for receiving status notification when adding or removing a file-system root. FileSystemRegistry Central registry for listeners that need to add or remove a file system. ConnectionClosedException Exception thrown when a method of a file connection is invoked but cannot be completed because the connection is closed.
To find out whether it is, invoke System. Another useful property is the file. An application opens a connection using Connector. The readable attribute for the file on the actual file system is set immediately upon invocation of this method. If the file system doesn't support a settable read attribute, this method is ignored and canRead always returns true. Parameters: readable - The new state of the readable flag of the selected file.
Throws: IOException - If the connection's target does not exist or is not accessible. SecurityException - If the security of the application does not have write access to the connection's target. IllegalModeException - If the application has write access to the connection's target but has opened the connection in Connector. The writable attribute for the file on the actual file system is set immediately upon invocation of the method.
If the file system doesn't support a settable write attribute, this method is ignored and canWrite always returns true. Parameters: writable - The new state of the writable flag of the selected file. The attribute is applied to the file on the actual file system immediately upon invocation of this method if the file system and platform support it.
If the file system doesn't support a hidden attribute, this method is ignored and isHidden always returns false. Since the exact definition of hidden is system-dependent, this method only works on file systems that support a settable file attribute. For example, on Win32 and FAT file systems, a file may be considered hidden if it has been marked as such in the file's attributes; therefore this method is applicable.
However on UNIX systems a file may be considered to be hidden if its name begins with a period character. In the UNIX case, this method can be ignored; to make a file hidden, use the rename method. Parameters: hidden - The new state of the hidden flag of the selected file. The directory is the connection's target as specified in Connector. Returns: An Enumeration of strings, denoting the files and directories in the directory.
The string returned contains only the file or directory name and does not contain any path prefix. To get a complete path for each file or directory, prepend FileConnection.
The Enumeration has zero length if the directory is empty. Any hidden files and directories in the directory are not included in the returned list. Any current or parent directory indication ". Parameters: filter - String against which all files and directories are matched for retrieval.
Returns: An Enumeration of strings, denoting the files and directories in the directory that match the filter. The Enumeration has zero length if the directory is empty or if no files or directories are found matching the given filter. SecurityException - if the security of the application does not have read access for the directory. NullPointerException - If filter is null. IllegalArgumentException - If a filter contains any path specification or is an invalid filename for the platform.
The Upon invocation of this method, the file is created immediately on the actual file system. Files are created with zero length and data can be put into the file through output streams opened on the file. This method does not create any directories specified in the file's path. Throws: SecurityException - If the security of the application does not have write access for the file. IllegalModeException - If the application does have write access to the file but has opened the connection in Connector.
Upon invocation of this method, the directory is created immediately on the actual file system. Directories in the specified path are not recursively created and must be explicitly created before subdirectories can be created.
Throws: SecurityException - If the security of the application does not have write access to the directory. IllegalModeException - If the application does have write access to the directory but has opened the connection in Connector. IOException - If invoked on an existing directory or on any file create is used to create files , the target file sytem is not accessible, or an unspecified error occurs preventing creation of the directory.
Returns: true if the connnection's target exists and is accessible, otherwise false. Returns: true if the connection's target exists, is accessible, and is a directory; otherwise false. Upon invocation of this method, the file or directory is deleted immediately on the actual file system. Datagram This class defines an abstract interface for datagram packets. DatagramConnection This interface defines the capabilities that a datagram connection must have.
InputConnection This interface defines the capabilities that an input stream connection must have. OutputConnection This interface defines the capabilities that an output stream connection must have.
The mode provided in the open method Connector. These methods have implied request for access rights i. Should the application not be granted the appropriate read or write access to the file or file system by the profile authorization scheme, a RuntimeException java.
SecurityException is thrown. File access through the File Connection API may be restricted to files that are within a public context and not deemed private or sensitive. This restriction is intended to protect the device's and other users' files and data from both malicious and unintentional access.
Access to files and directories that are private to another application, files and directories that are private to a different user than the current user, system configuration files, and device and OS specific files and directories may be restricted. In these situations, a RuntimeException java. SecurityException is thrown from the Connector. String getPath Returns the path excluding the file or directory name and the "file" URL schema and host from where the file or directory specified in the Connector.
Enumeration list Gets a list of all files and directories contained in a directory. Enumeration list String filter, boolean includeHidden Gets a filtered list of files and directories contained in a directory. InputStream openInputStream Open and return an input stream for a connection. OutputStream openOutputStream Open and return an output stream for a connection. OutputStream openOutputStream long byteOffset This method opens an output stream and positions it at the indicated byte offset in the file.
Methods inherited from interface javax. Connection close Methods inherited from interface javax. Connection close Method Detail isOpen boolean isOpen Returns an indication of whether the file connection is currently open or not. Returns: true if the file connection is open, false otherwise. The connection's target must already exist and be accessible for the input stream to be created. IllegalModeException - if the application does have read access to the connection's target but has opened the connection in Connector.
WRITE mode. SecurityException - If the application is not granted read access to the connection's target. The output stream is positioned at the start of the file. Writing data to the output stream overwrites the contents of the files i. Writing data to output streams beyond the current end of file automatically extends the file size. The connection's target must already exist and be accessible for the output stream to be created.
Changes made to a file through an output stream may not be immediately made to the actual file residing on the file system because platform and implementation specific use of caching and buffering of the data. Steam contents and file length extensions are not necessarily visible outside of the application immediately unless flush is called on the stream.
IllegalModeException - if the application does have write access to the connection's target but has opened the connection in Connector. READ mode. SecurityException - If the application is not granted write access to the connection's target.
See Also: FileConnection. Data written to the returned output stream at that position overwrites any existing data until EOF is reached, and then additional data is appended. Parameters: byteOffset - number of bytes to skip over from the beginning of the file when positioning the start of the OutputStream.
If the provided offset is larger than or equal to the current file size, the OutputStream is positioned at the current end of the file for appending. Returns: an open OutputStream positioned at the byte offset in the file, or the end of the file if the offset is greater than the size of the file.
SecurityException - if the security if the application does not allow write access to the file. IllegalArgumentException - if byteOffset has a negative value. Returns: The total size of the file system in bytes, or -1 if the file system is not accessible.
0コメント