×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    setFileConnection

    Firstly, I set FileConnection to photos directory.

    fileconnection=(FileConnection) Connector.open("file:///root1/photos",Connector.READ_WRITE);

    Then I reset the FileConnection to a file under the photos directory.

    fileconnection.setFileConnection("momo.txt");

    but I can’t reset the FileConnection to photos directory again. Why?

    fileconnection.setFileConnection("photos");

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: setFileConnection

    Quote Originally Posted by komomo View Post
    Firstly, I set FileConnection to photos directory.

    fileconnection=(FileConnection) Connector.open("file:///root1/photos",Connector.READ_WRITE);

    Then I reset the FileConnection to a file under the photos directory.

    fileconnection.setFileConnection("momo.txt");

    but I can’t reset the FileConnection to photos directory again. Why?

    fileconnection.setFileConnection("photos");
    try fileconnection.setFileConnection("..") for this.

    As per API doc

    setFileConnection


    public void setFileConnection(java.lang.String fileName)

    throws java.io.IOException
    Resets this FileConnection object to another file or directory. This allows reuse of the FileConnection object for directory traversal. The current FileConnection object must refer to a directory, and the new file or directory must exist within this directory, or may be the string ".." used to indicate the parent directory for the current connection). The FileConnection instance object remains open and available for use, referring now to the newly specified file or directory.
    Parameters:
    fileName - name of the file or directory to which this FileConnection is reset. The fileName must be one of the values returned from the list(String, boolean) method, or the string ".." to indicate the parent directory of the current connection. The fileName must not contain any additional path specification; i.e. the file or directory must reside within the current directory.
    Throws:
    java.lang.NullPointerException - if fileName is null.
    java.lang.SecurityException - if the security of the application does not have the security access to the specified file or directory as requested in the Connector.open method invocation that originally opened this FileConnection.
    java.lang.IllegalArgumentException - if fileName contains any path specification or does not yet exist.
    java.io.IOException - if the current FileConnection is opened on a file, the connection's target is not accessible, or fileName is an invalid filename for the platform (e.g. contains characters invalid in a filename on the platform).
    ConnectionClosedException - if the connection is closed.
    Thanks,
    Ekta

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •