Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk.platform
Interface GCFFile

All Known Implementing Classes:
  BaseGCFFile, GCFFileImpl, GCFFileImpl

    public interface GCFFile

Interface for native peer of a file handle

Method Summary
`void` | `close()` Close file associated with this handler.
`void` | `closeForRead()` Closes for reading the file that was open by openForRead method.
`void` | `closeForReadWrite()` Closes the file for both reading and writing.
`void` | `closeForWrite()` Closes for writing the file that was open by openForWrite method.
`void` | `connect(String rootName, String fileName)` Connect file handler to the abstract file target.
`void` | `create()` Create file corresponding to this file handler.
`void` | `delete()` Deletes the file or directory associated with this handler.
`boolean` | `exists()` Check is file or directory corresponding to this filehandler exists.
`long` | `fileSize()` Determines the size of a file on the file system.
`void` | `flush()` Forces any buffered output bytes to be written out.
`String` | `illegalFileNameChars()` Returns a string that contains all characters forbidden for the use on the given platform except "/" (forward slash) which is always considered illegal.
`boolean` | `isDirectory()` Check is file corresponding to this filehandler exists and is a directory.
`void` | `openForRead()` Open the file for reading, on the underlying file system.
`void` | `openForWrite()` Open the file for writing, on the underlying file system.
`void` | `positionForWrite(long offset)` Sets the location for the next write operation.
`int` | `read(byte[] b, int off, int len)` Reads up to `len` bytes of data from the input stream into an array of bytes, blocks until at least one byte is available.
`int` | `write(byte[] b, int off, int len)` Writes `len` bytes from the specified byte array starting at offset `off` to this output stream.

Method Detail

### connect

    void connect(String rootName,
                 String fileName)

  Connect file handler to the abstract file target. This operation should not trigger any access to the native filesystem.

  Parameters:
    `rootName` - The name of the root directory.
    `fileName` - Full path to the file to be handled by this handler.
  Throws:
    `IllegalArgumentException` - if filename contains characters not allowed by the file system. This check should not involve any actual access to the filesystem.

### openForRead

    void openForRead()
                     throws IOException

  Open the file for reading, on the underlying file system. File name is passed in the link#connect() method.

  Throws:
    `IOException` - if file is directory, file does not exists, if file is already open for read or other I/O error occurs

### closeForRead

    void closeForRead()
                      throws IOException

  Closes for reading the file that was open by openForRead method. If the file is already closed for reading this method does nothing.

  Throws:
    `IOException` - if file is directory, file does not exists or other I/O error occurs

### openForWrite

    void openForWrite()
                      throws IOException

  Open the file for writing, on the underlying file system. File name is passed in the link#connect() method.

  Throws:
    `IOException` - if file is directory, file does not exists, i if file is already open for write or other I/O error occurs

### closeForWrite

    void closeForWrite()
                       throws IOException

  Closes for writing the file that was open by openForWrite method. If the file is already closed for writing this method does nothing.

  Throws:
    `IOException` - if file is directory, file does not exists or other I/O error occurs

### closeForReadWrite

    void closeForReadWrite()
                           throws IOException

  Closes the file for both reading and writing. If the file is already closed for reading and writing this method does nothing.

  Throws:
    `IOException` - if file is directory, file does not exists or other I/O error occurs

### create

    void create()
                throws IOException

  Create file corresponding to this file handler. The file is created immediately on the actual file system upon invocation of this method. Files are created with zero length and data can be put into the file through write method after opening the file.This method does not create any directories specified in the file's path.

  Throws:
    `IOException` - if invoked on the existing file or unexpected error occurs.

### exists

    boolean exists()

  Check is file or directory corresponding to this filehandler exists.

  Returns:
    true if file exists, otherwise false

### isDirectory

    boolean isDirectory()

  Check is file corresponding to this filehandler exists and is a directory.

  Returns:
    true if directory exists, otherwise false

### delete

    void delete()
                throws IOException

  Deletes the file or directory associated with this handler. The file or directory is deleted immediately on the actual file system upon invocation of this method. Previously open native file should be closed.The handler instance object remains connected and available for use.

  Throws:
    `IOException` - If the target is a directory and it is not empty, the connection target does not exist or is unaccessible, or an unspecified error occurs preventing deletion of the target.

### fileSize

    long fileSize()
                  throws IOException

  Determines the size of a file on the file system. The size of a file always represents the number of bytes contained in the file; there is no pre-allocated but empty space in a file. Users should perform an explicit `flush()` on any open output streams to the file prior to invoking this method to ensure accurate results.

  Returns:
    The size in bytes of the selected file, or -1 if the file does not exist or is not accessible.
  Throws:
    `IOException` - if the method is invoked on a directory.

### read

    int read(byte[] b,
             int off,
             int len)
             throws IOException

  Reads up to `len` bytes of data from the input stream into an array of bytes, blocks until at least one byte is available.

  Parameters:
    `b` - the buffer into which the data is read.
    `off` - the start offset in array `b` at which the data is written.
    `len` - the maximum number of bytes to read.
  Returns:
    the total number of bytes read into the buffer, or `-1` if there is no more data because the end of the stream has been reached.
  Throws:
    `IOException` - if an I/O error occurs.

### write

    int write(byte[] b,
              int off,
              int len)
              throws IOException

  Writes `len` bytes from the specified byte array starting at offset `off` to this output stream.

  Polling the native code is done here to allow for simple asynchronous native code to be written. Not all implementations work this way (they block in the native code) but the same Java code works for both.

  Parameters:
    `b` - the data.
    `off` - the start offset in the data.
    `len` - the number of bytes to write.
  Returns:
    number of bytes written
  Throws:
    `IOException` - if an I/O error occurs. In particular, an `IOException` is thrown if the output stream is closed.

### flush

    void flush()
               throws IOException

  Forces any buffered output bytes to be written out. The general contract of `flush` is that calling it is an indication that, if any bytes previously written that have been buffered by the connection, should immediately be written to their intended destination.

  The `flush` method of `ConnectionBaseAdapter` does nothing.

  Throws:
    `IOException` - if an I/O error occurs.

### positionForWrite

    void positionForWrite(long offset)
                          throws IOException

  Sets the location for the next write operation.

  Parameters:
    `offset` - location for next write
  Throws:
    `IOException` - if an error occurs

### illegalFileNameChars

    String illegalFileNameChars()

  Returns a string that contains all characters forbidden for the use on the given platform except "/" (forward slash) which is always considered illegal. If there are no such characters an empty string is returned.

  Returns:
    string of characters not allowed in file names

### close

    void close()
               throws IOException

  Close file associated with this handler. Open file and all system resources should be released by this call. Handler object can be reused by subsequent call to connect().

  Throws:
    `IOException` - if I/O error occurs

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"